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.4 by schorsch, Thu Jun 26 00:58:11 2003 UTC vs.
Revision 3.13 by greg, Sat Dec 12 19:01:00 2009 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 11 | Line 11 | static const char RCSid[] = "$Id";
11  
12   #include "copyright.h"
13  
14 #include "ranimove.h"
14   #include <time.h>
15 < #ifndef _WIN32
15 > #ifdef _WIN32
16 >  #include <winsock.h> /* struct timeval. XXX find a replacement? */
17 > #else
18    #include <sys/time.h>
19   #endif
20   #include <ctype.h>
21 + #include <string.h>
22  
23 + #include "paths.h"
24 + #include "ranimove.h"
25 +
26   int             NVARS = NV_INIT; /* total number of variables */
27  
28   VARIABLE        vv[] = VV_INIT; /* variable-value pairs */
# Line 57 | Line 62 | int            haveprio = 0;   /* high-level saliency specified */
62   int             gargc;          /* global argc for printargs */
63   char            **gargv;        /* global argv for printargs */
64  
65 + static void setdefaults(void);
66 + static void setmove(struct ObjMove      *om, char       *ms);
67 + static void setrendparams(char          *optf, char             *qval);
68 + static void getradfile(char     *rfargs);
69 + static void animate(void);
70 + static int countviews(void); /* XXX duplicated function */
71 + static char * getobjname(struct ObjMove *om);
72 + static char * getxf(struct ObjMove      *om, int        n);
73  
74 +
75   int
76 < main(argc, argv)
77 < int     argc;
78 < char    *argv[];
76 > main(
77 >        int     argc,
78 >        char    *argv[]
79 > )
80   {
81          int     explicate = 0;
82          char    *cfname;
# Line 94 | Line 109 | char   *argv[];
109                  case 'f':                       /* frame range */
110                          switch (sscanf(argv[++i], "%d,%d", &fbeg, &fend)) {
111                          case 2:
112 <                                if ((fbeg <= 0 | fend < fbeg))
112 >                                if ((fbeg <= 0) | (fend < fbeg))
113                                          goto userr;
114                                  break;
115                          case 1:
# Line 138 | Line 153 | char   *argv[];
153                                                  /* all done */
154          if (lorendoptf[0])
155                  unlink(lorendoptf);
156 <        if (hirendoptf[0])
156 >        if (hirendoptf[0] && strcmp(hirendoptf, lorendoptf))
157                  unlink(hirendoptf);
158          if (objtmpf[0])
159                  unlink(objtmpf);
# Line 148 | Line 163 | userr:
163   "Usage: %s [-n nprocs][-f beg,end][-t sec][-d jnd][-s][-w][-e] anim_file\n",
164                          progname);
165          quit(1);
166 +        return 1; /* pro forma return */
167   }
168  
169  
170   void
171 < eputs(s)                                /* put string to stderr */
172 < register char  *s;
171 > eputs(                          /* put string to stderr */
172 >        register char  *s
173 > )
174   {
175          static int  midline = 0;
176  
# Line 172 | Line 189 | register char  *s;
189  
190  
191   void
192 < setdefaults()                   /* set default values */
192 > quit(ec)                        /* make sure exit is called */
193 > int     ec;
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 + {
204          int     nviews;
205          int     decades;
206          char    buf[256];
# Line 244 | Line 271 | setdefaults()                  /* set default values */
271          setrendparams(lorendoptf, vval(LOWQ));
272          ray_save(&lorendparams);
273          curparams = &lorendparams;
274 <        twolevels = bcmp(&lorendparams, &hirendparams, sizeof(RAYPARAMS));
274 >        twolevels = memcmp(&lorendparams, &hirendparams, sizeof(RAYPARAMS));
275   }
276  
277  
278 < void
279 < setmove(om, ms)                 /* assign a move object from spec. */
280 < struct ObjMove  *om;
281 < char    *ms;
278 > static void
279 > setmove(                        /* assign a move object from spec. */
280 >        struct ObjMove  *om,
281 >        char    *ms
282 > )
283   {
284          char    parname[128];
285          char    *cp;
# Line 296 | Line 324 | char   *ms;
324                  if (isflt(om->prio_file)) {
325                          om->prio = atof(om->prio_file);
326                          om->prio_file[0] = '\0';
327 <                        haveprio |= (om->prio < 0.95 | om->prio > 1.05);
327 >                        haveprio |= ((om->prio < 0.95) | (om->prio > 1.05));
328                  } else
329                          haveprio = 1;
330          } else
# Line 308 | Line 336 | badspec:
336   }
337  
338  
339 < void
340 < setrendparams(optf, qval)       /* set global rendering parameters */
341 < char            *optf;
342 < char            *qval;
339 > static void
340 > setrendparams(  /* set global rendering parameters */
341 >        char            *optf,
342 >        char            *qval
343 > )
344   {
345          char    *argv[1024];
346          char    **av = argv;
# Line 331 | Line 360 | char           *qval;
360          if (qval != NULL && qval[0] == '-')
361                  ac += wordstring(av+ac, qval);
362  
363 <                                /* start with default parameters */
364 <        ray_defaults(NULL);
363 >                                /* restore default parameters */
364 >        ray_restore(NULL);
365                                  /* set what we have */
366          for (i = 0; i < ac; i++) {
367                  while ((rval = expandarg(&ac, &av, i)) > 0)
# Line 346 | Line 375 | char           *qval;
375                          continue;
376                  }
377                  rval = getrenderopt(ac-i, av+i);
378 <                if (rval >= 0) {
379 <                        i += rval;
380 <                        continue;
378 >                if (rval < 0) {
379 >                        sprintf(errmsg, "bad render option at '%s'", av[i]);
380 >                        error(USER, errmsg);
381                  }
382 <                sprintf(errmsg, "bad render option at '%s'", av[i]);
354 <                error(USER, errmsg);
382 >                i += rval;
383          }
384   }
385  
386  
387 < void
388 < getradfile(rfargs)              /* run rad and get needed variables */
389 < char    *rfargs;
387 > static void
388 > getradfile(             /* run rad and get needed variables */
389 >        char    *rfargs
390 > )
391   {
392          static short    mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1};
393          char    combuf[256];
394          register int    i;
395          register char   *cp;
396 <        char    *pippt;
396 >        char    *pippt = NULL;
397                                          /* create rad command */
398          strcpy(lorendoptf, "ranim0.opt");
399          sprintf(combuf,
# Line 385 | Line 414 | char   *rfargs;
414                          pippt = NULL;
415                  }
416          if (pippt != NULL)
417 <                strcpy(pippt, "> /dev/null");   /* nothing to match */
417 >                strcpy(pippt, "> " NULL_DEVICE);        /* nothing to match */
418          else {
419                  strcpy(cp, ")[ \t]*=' > ranimove.var");
420                  cp += 11;               /* point to file name */
# Line 407 | Line 436 | char   *rfargs;
436   }
437  
438  
439 < void
440 < animate()                       /* run through animation */
439 > static void
440 > animate(void)                   /* run through animation */
441   {
442          int     rpass;
443  
# Line 439 | Line 468 | animate()                      /* run through animation */
468   }
469  
470  
471 < VIEW *
472 < getview(n)                      /* get view number n */
473 < int     n;
471 > extern VIEW *
472 > getview(                        /* get view number n */
473 >        int     n
474 > )
475   {
476          static FILE     *viewfp = NULL;         /* view file pointer */
477          static int      viewnum = 0;            /* current view number */
# Line 453 | Line 483 | int    n;
483                          fclose(viewfp);
484                          viewfp = NULL;
485                          viewnum = 0;
486 <                        copystruct(&curview, &stdview);
486 >                        curview = stdview;
487                  }
488                  return(NULL);
489          }
# Line 469 | Line 499 | int    n;
499                          perror(vval(VIEWFILE));
500                          quit(1);
501                  }
502 <                copystruct(&curview, &stdview);
502 >                curview = stdview;
503                  viewnum = 0;
504          }
505          if (n < 0) {                            /* get next view */
# Line 489 | Line 519 | int    n;
519   }
520  
521  
522 < int
523 < countviews()                    /* count views in view file */
522 > static int
523 > countviews(void)                        /* count views in view file */
524   {
525          int     n;
526  
# Line 502 | Line 532 | countviews()                   /* count views in view file */
532   }
533  
534  
535 < char *
536 < getexp(n)                       /* get exposure for nth frame */
537 < int     n;
535 > extern char *
536 > getexp(                 /* get exposure for nth frame */
537 >        int     n
538 > )
539   {
540          extern char     *fskip();
541          static char     expval[32];
# Line 556 | Line 587 | formerr:
587          sprintf(errmsg, "%s: exposure format error on line %d",
588                          vval(EXPOSURE), curfrm);
589          error(USER, errmsg);
590 +        return NULL; /* pro forma return */
591   }
592  
593  
594 < double
595 < expspec_val(s)                  /* get exposure value from spec. */
596 < char    *s;
594 > extern double
595 > expspec_val(                    /* get exposure value from spec. */
596 >        char    *s
597 > )
598   {
599          double  expval;
600  
# Line 569 | Line 602 | char   *s;
602                  return(1.0);
603  
604          expval = atof(s);
605 <        if ((s[0] == '+' | s[0] == '-'))
605 >        if ((s[0] == '+') | (s[0] == '-'))
606                  return(pow(2.0, expval));
607          return(expval);
608   }
609  
610  
611 < char *
612 < getoctspec(n)                   /* get octree for the given frame */
613 < int     n;
611 > extern char *
612 > getoctspec(                     /* get octree for the given frame */
613 >        int     n
614 > )
615   {
616          static char     combuf[1024];
617          int             cfm = 0;
# Line 629 | Line 663 | int    n;
663   }
664  
665  
666 < char *
667 < getobjname(om)                  /* get fully qualified object name */
668 < register struct ObjMove *om;
666 > static char *
667 > getobjname(                     /* get fully qualified object name */
668 >        register struct ObjMove *om
669 > )
670   {
671          static char     objName[512];
672          register char   *cp = objName;
# Line 647 | Line 682 | register struct ObjMove        *om;
682   }
683  
684  
685 < char *
686 < getxf(om, n)                    /* get total transform for object */
687 < register struct ObjMove *om;
688 < int     n;
685 > static char *
686 > getxf(                  /* get total transform for object */
687 >        register struct ObjMove *om,
688 >        int     n
689 > )
690   {
691          static char     xfsbuf[4096];
692          char            *xfp;
# Line 758 | Line 794 | int    n;
794                  om->cprio = om->prio;
795          }
796                                          /* XXX bxfm relies on call order */
797 <        if (framestep)
797 >        if (framestep) {
798                  if (invmat4(om->bxfm, om->cxfm))
799                          multmat4(om->bxfm, om->bxfm, oxf.xfm);
800                  else
801                          setident4(om->bxfm);
802 +        }
803                                          /* all done */
804          return(xfp);
805   }
806  
807  
808 < int
809 < getmove(obj)                            /* find matching move object */
810 < OBJECT  obj;
808 > extern int
809 > getmove(                                /* find matching move object */
810 >        OBJECT  obj
811 > )
812   {
813          static int      lasti;
814          static OBJECT   lasto = OVOID;
# Line 788 | Line 826 | OBJECT obj;
826                  objnm = obj_move[i].name;
827                  len = strlen(objnm);
828                  if (!strncmp(onm, objnm, len)) {
829 <                        if ((obj_move[i].parent < 0 & onm[len] == '.'))
829 >                        if ((obj_move[i].parent < 0) & (onm[len] == '.'))
830                                  break;
831                          objnm = getobjname(&obj_move[i]) + len;
832                          len2 = strlen(objnm);
# Line 801 | Line 839 | OBJECT obj;
839   }
840  
841  
842 < double
843 < obj_prio(obj)                   /* return priority for object */
844 < OBJECT  obj;
842 > extern double
843 > obj_prio(                       /* return priority for object */
844 >        OBJECT  obj
845 > )
846   {
847          int     moi;
848          
# Line 813 | Line 852 | OBJECT obj;
852   }
853  
854  
855 < double
856 < getTime()                       /* get current time (CPU or real) */
855 > extern double
856 > getTime(void)                   /* get current time (CPU or real) */
857   {
858          struct timeval  time_now;
859                                          /* return CPU time if one process */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines