| 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 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
void |
| 172 |
< |
eputs(s) /* put string to stderr */ |
| 173 |
< |
register char *s; |
| 172 |
> |
eputs( /* put string to stderr */ |
| 173 |
> |
char *s |
| 174 |
> |
) |
| 175 |
|
{ |
| 176 |
|
static int midline = 0; |
| 177 |
|
|
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
|
| 192 |
+ |
void |
| 193 |
+ |
quit(int ec) /* make sure exit is called */ |
| 194 |
+ |
{ |
| 195 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
| 196 |
+ |
ray_pclose(0); |
| 197 |
+ |
else if (ray_pnprocs < 0) |
| 198 |
+ |
_exit(ec); /* avoid flush in child */ |
| 199 |
+ |
exit(ec); |
| 200 |
+ |
} |
| 201 |
+ |
|
| 202 |
+ |
|
| 203 |
|
static void |
| 204 |
|
setdefaults(void) /* set default values */ |
| 205 |
|
{ |
| 351 |
|
av[ac=0] = NULL; |
| 352 |
|
/* load options from file, first */ |
| 353 |
|
if (optf != NULL && *optf) { |
| 354 |
< |
ac = wordfile(av, optf); |
| 354 |
> |
ac = wordfile(av, 1024, optf); |
| 355 |
|
if (ac < 0) { |
| 356 |
|
sprintf(errmsg, "cannot load options file \"%s\"", |
| 357 |
|
optf); |
| 360 |
|
} |
| 361 |
|
/* then from options string */ |
| 362 |
|
if (qval != NULL && qval[0] == '-') |
| 363 |
< |
ac += wordstring(av+ac, qval); |
| 363 |
> |
ac += wordstring(av+ac, 1024-ac, qval); |
| 364 |
|
|
| 365 |
|
/* restore default parameters */ |
| 366 |
|
ray_restore(NULL); |
| 393 |
|
{ |
| 394 |
|
static short mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1}; |
| 395 |
|
char combuf[256]; |
| 396 |
< |
register int i; |
| 397 |
< |
register char *cp; |
| 396 |
> |
int i; |
| 397 |
> |
char *cp; |
| 398 |
|
char *pippt = NULL; |
| 399 |
|
/* create rad command */ |
| 400 |
|
strcpy(lorendoptf, "ranim0.opt"); |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
|
| 473 |
< |
extern VIEW * |
| 473 |
> |
VIEW * |
| 474 |
|
getview( /* get view number n */ |
| 475 |
|
int n |
| 476 |
|
) |
| 505 |
|
viewnum = 0; |
| 506 |
|
} |
| 507 |
|
if (n < 0) { /* get next view */ |
| 508 |
< |
register int c = getc(viewfp); |
| 508 |
> |
int c = getc(viewfp); |
| 509 |
|
if (c == EOF) |
| 510 |
|
return(NULL); /* that's it */ |
| 511 |
|
ungetc(c, viewfp); |
| 534 |
|
} |
| 535 |
|
|
| 536 |
|
|
| 537 |
< |
extern char * |
| 537 |
> |
char * |
| 538 |
|
getexp( /* get exposure for nth frame */ |
| 539 |
|
int n |
| 540 |
|
) |
| 543 |
|
static char expval[32]; |
| 544 |
|
static FILE *expfp = NULL; |
| 545 |
|
static int curfrm = 0; |
| 546 |
< |
register char *cp; |
| 546 |
> |
char *cp; |
| 547 |
|
|
| 548 |
|
if (n == 0) { /* signal to close file */ |
| 549 |
|
if (expfp != NULL) { |
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
|
| 596 |
< |
extern double |
| 596 |
> |
double |
| 597 |
|
expspec_val( /* get exposure value from spec. */ |
| 598 |
|
char *s |
| 599 |
|
) |
| 610 |
|
} |
| 611 |
|
|
| 612 |
|
|
| 613 |
< |
extern char * |
| 613 |
> |
char * |
| 614 |
|
getoctspec( /* get octree for the given frame */ |
| 615 |
|
int n |
| 616 |
|
) |
| 617 |
|
{ |
| 618 |
|
static char combuf[1024]; |
| 619 |
< |
int cfm = 0; |
| 619 |
> |
static int cfm = 0; |
| 620 |
|
int uses_inline; |
| 621 |
|
FILE *fp; |
| 622 |
|
int i; |
| 623 |
|
/* is octree static? */ |
| 624 |
|
if (!vdef(MOVE)) |
| 625 |
|
return(vval(OCTREEF)); |
| 626 |
< |
/* done already */ |
| 626 |
> |
/* done already? */ |
| 627 |
|
if (n == cfm) |
| 628 |
|
return(combuf); |
| 629 |
|
/* else create object file */ |
| 630 |
< |
strcpy(objtmpf, "movinobj.rad"); |
| 618 |
< |
fp = fopen(objtmpf, "w"); |
| 630 |
> |
fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w"); |
| 631 |
|
if (fp == NULL) { |
| 632 |
|
sprintf(errmsg, "cannot write to moving objects file '%s'", |
| 633 |
|
objtmpf); |
| 658 |
|
vdef(OCONV) ? vval(OCONV) : "", |
| 659 |
|
vval(OCTREEF), objtmpf); |
| 660 |
|
else |
| 661 |
< |
sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -", |
| 662 |
< |
objtmpf, vval(OCTREEF)); |
| 661 |
> |
sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -", |
| 662 |
> |
objtmpf, vdef(OCONV) ? vval(OCONV) : "", |
| 663 |
> |
vval(OCTREEF)); |
| 664 |
|
return(combuf); |
| 665 |
|
} |
| 666 |
|
|
| 667 |
|
|
| 668 |
|
static char * |
| 669 |
|
getobjname( /* get fully qualified object name */ |
| 670 |
< |
register struct ObjMove *om |
| 670 |
> |
struct ObjMove *om |
| 671 |
|
) |
| 672 |
|
{ |
| 673 |
|
static char objName[512]; |
| 674 |
< |
register char *cp = objName; |
| 674 |
> |
char *cp = objName; |
| 675 |
|
|
| 676 |
|
strcpy(cp, om->name); |
| 677 |
|
while (om->parent >= 0) { |
| 686 |
|
|
| 687 |
|
static char * |
| 688 |
|
getxf( /* get total transform for object */ |
| 689 |
< |
register struct ObjMove *om, |
| 689 |
> |
struct ObjMove *om, |
| 690 |
|
int n |
| 691 |
|
) |
| 692 |
|
{ |
| 699 |
|
char *av[64]; |
| 700 |
|
int ac; |
| 701 |
|
int i; |
| 702 |
< |
register char *cp; |
| 702 |
> |
char *cp; |
| 703 |
|
/* get parent transform, first */ |
| 704 |
|
if (om->parent >= 0) |
| 705 |
|
xfp = getxf(&obj_move[om->parent], n); |
| 807 |
|
} |
| 808 |
|
|
| 809 |
|
|
| 810 |
< |
extern int |
| 810 |
> |
int |
| 811 |
|
getmove( /* find matching move object */ |
| 812 |
|
OBJECT obj |
| 813 |
|
) |
| 816 |
|
static OBJECT lasto = OVOID; |
| 817 |
|
char *onm, *objnm; |
| 818 |
|
int len, len2; |
| 819 |
< |
register int i; |
| 819 |
> |
int i; |
| 820 |
|
|
| 821 |
|
if (obj == OVOID) |
| 822 |
|
return(-1); |
| 841 |
|
} |
| 842 |
|
|
| 843 |
|
|
| 844 |
< |
extern double |
| 844 |
> |
double |
| 845 |
|
obj_prio( /* return priority for object */ |
| 846 |
|
OBJECT obj |
| 847 |
|
) |
| 854 |
|
} |
| 855 |
|
|
| 856 |
|
|
| 857 |
< |
extern double |
| 857 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 858 |
> |
/* replacement function for Windoze */ |
| 859 |
> |
static int |
| 860 |
> |
gettimeofday(struct timeval *tp, void *dummy) |
| 861 |
> |
{ |
| 862 |
> |
FILETIME ft; |
| 863 |
> |
LARGE_INTEGER li; |
| 864 |
> |
__int64 t; |
| 865 |
> |
|
| 866 |
> |
SYSTEMTIME st; |
| 867 |
> |
FILETIME ft2; |
| 868 |
> |
LARGE_INTEGER li2; |
| 869 |
> |
__int64 t2; |
| 870 |
> |
|
| 871 |
> |
st.wYear = 1970; |
| 872 |
> |
st.wHour = 0; |
| 873 |
> |
st.wMinute = 0; |
| 874 |
> |
st.wSecond = 0; |
| 875 |
> |
st.wMilliseconds = 1; |
| 876 |
> |
|
| 877 |
> |
SystemTimeToFileTime(&st, &ft2); |
| 878 |
> |
li2.LowPart = ft2.dwLowDateTime; |
| 879 |
> |
li2.HighPart = ft2.dwHighDateTime; |
| 880 |
> |
t2 = li2.QuadPart; |
| 881 |
> |
|
| 882 |
> |
GetSystemTimeAsFileTime(&ft); |
| 883 |
> |
li.LowPart = ft.dwLowDateTime; |
| 884 |
> |
li.HighPart = ft.dwHighDateTime; |
| 885 |
> |
t = li.QuadPart; |
| 886 |
> |
t -= t2; // From 1970 |
| 887 |
> |
t /= 10; // In microseconds |
| 888 |
> |
tp->tv_sec = (long)(t / 1000000); |
| 889 |
> |
tp->tv_usec = (long)(t % 1000000); |
| 890 |
> |
return 0; |
| 891 |
> |
} |
| 892 |
> |
|
| 893 |
> |
#endif |
| 894 |
> |
|
| 895 |
> |
double |
| 896 |
|
getTime(void) /* get current time (CPU or real) */ |
| 897 |
|
{ |
| 898 |
|
struct timeval time_now; |