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