--- ray/src/util/ranimove.c 2009/12/12 19:01:00 3.13 +++ ray/src/util/ranimove.c 2016/03/06 01:13:18 3.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ranimove.c,v 3.13 2009/12/12 19:01:00 greg Exp $"; +static const char RCSid[] = "$Id: ranimove.c,v 3.16 2016/03/06 01:13:18 schorsch Exp $"; #endif /* * Radiance object animation program @@ -12,7 +12,7 @@ static const char RCSid[] = "$Id: ranimove.c,v 3.13 20 #include "copyright.h" #include -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) #include /* struct timeval. XXX find a replacement? */ #else #include @@ -20,6 +20,7 @@ static const char RCSid[] = "$Id: ranimove.c,v 3.13 20 #include #include +#include "platform.h" #include "paths.h" #include "ranimove.h" @@ -614,19 +615,18 @@ getoctspec( /* get octree for the given frame */ ) { static char combuf[1024]; - int cfm = 0; + static int cfm = 0; int uses_inline; FILE *fp; int i; /* is octree static? */ if (!vdef(MOVE)) return(vval(OCTREEF)); - /* done already */ + /* done already? */ if (n == cfm) return(combuf); /* else create object file */ - strcpy(objtmpf, "movinobj.rad"); - fp = fopen(objtmpf, "w"); + fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w"); if (fp == NULL) { sprintf(errmsg, "cannot write to moving objects file '%s'", objtmpf); @@ -657,8 +657,9 @@ getoctspec( /* get octree for the given frame */ vdef(OCONV) ? vval(OCONV) : "", vval(OCTREEF), objtmpf); else - sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -", - objtmpf, vval(OCTREEF)); + sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -", + objtmpf, vdef(OCONV) ? vval(OCONV) : "", + vval(OCTREEF)); return(combuf); } @@ -851,6 +852,44 @@ obj_prio( /* return priority for object */ return(obj_move[moi].cprio); } + +#if defined(_WIN32) || defined(_WIN64) + /* replacement function for Windoze */ +static int +gettimeofday(struct timeval *tp, void *dummy) +{ + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + + SYSTEMTIME st; + FILETIME ft2; + LARGE_INTEGER li2; + __int64 t2; + + st.wYear = 1970; + st.wHour = 0; + st.wMinute = 0; + st.wSecond = 0; + st.wMilliseconds = 1; + + SystemTimeToFileTime(&st, &ft2); + li2.LowPart = ft2.dwLowDateTime; + li2.HighPart = ft2.dwHighDateTime; + t2 = li2.QuadPart; + + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; + t -= t2; // From 1970 + t /= 10; // In microseconds + tp->tv_sec = (long)(t / 1000000); + tp->tv_usec = (long)(t % 1000000); + return 0; +} + +#endif extern double getTime(void) /* get current time (CPU or real) */