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