ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ranimove.c
(Generate patch)

Comparing ray/src/util/ranimove.c (file contents):
Revision 3.10 by schorsch, Fri Mar 26 21:36:20 2004 UTC vs.
Revision 3.22 by greg, Wed Apr 23 02:35:26 2025 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char RCSid[] = "$Id";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   *  Radiance object animation program
# Line 12 | Line 12 | static const char RCSid[] = "$Id";
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>
# Line 20 | Line 20 | static const char RCSid[] = "$Id";
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  
# Line 83 | Line 85 | main(
85          int     i;
86  
87          progname = argv[0];                     /* get arguments */
88 +                                                /* initialize calcomp */
89 +        initfunc();
90          gargc = argc;
91          gargv = argv;
92          for (i = 1; i < argc && argv[i][0] == '-'; i++)
# Line 168 | Line 172 | userr:
172  
173  
174   void
175 < eputs(s)                                /* put string to stderr */
176 < register char  *s;
175 > eputs(                          /* put string to stderr */
176 >        const char  *s
177 > )
178   {
179          static int  midline = 0;
180  
# Line 187 | Line 192 | register char  *s;
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   {
# Line 338 | Line 354 | setrendparams( /* set global rendering parameters */
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);
# Line 347 | Line 363 | setrendparams( /* set global rendering parameters */
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);
# Line 380 | Line 396 | getradfile(            /* run rad and get needed variables */
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");
# Line 457 | Line 473 | animate(void)                  /* run through animation */
473   }
474  
475  
476 < extern VIEW *
476 > VIEW *
477   getview(                        /* get view number n */
478          int     n
479   )
# Line 492 | Line 508 | getview(                       /* get view number n */
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);
# Line 521 | Line 537 | countviews(void)                       /* count views in view file */
537   }
538  
539  
540 < extern char *
540 > char *
541   getexp(                 /* get exposure for nth frame */
542          int     n
543   )
544   {
529        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) {
# Line 580 | Line 595 | formerr:
595   }
596  
597  
598 < extern double
598 > double
599   expspec_val(                    /* get exposure value from spec. */
600          char    *s
601   )
# Line 597 | Line 612 | expspec_val(                   /* get exposure value from spec. */
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");
618 <        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);
# Line 646 | Line 660 | getoctspec(                    /* get octree for the given frame */
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) {
# Line 673 | Line 688 | getobjname(                    /* get fully qualified object name */
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   {
# Line 686 | Line 701 | getxf(                 /* get total transform for object */
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);
# Line 794 | Line 809 | getxf(                 /* get total transform for object */
809   }
810  
811  
812 < extern int
812 > int
813   getmove(                                /* find matching move object */
814          OBJECT  obj
815   )
# Line 803 | Line 818 | getmove(                               /* find matching move object */
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);
# Line 828 | Line 843 | getmove(                               /* find matching move object */
843   }
844  
845  
846 < extern double
846 > double
847   obj_prio(                       /* return priority for object */
848          OBJECT  obj
849   )
# Line 841 | Line 856 | obj_prio(                      /* return priority for object */
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines