| 1 | greg | 3.2 | /* RCSid $Id$ */ | 
| 2 | greg | 3.1 | /* | 
| 3 |  |  | *  ranimove.h | 
| 4 |  |  | * | 
| 5 |  |  | * Radiance object animation program | 
| 6 |  |  | * | 
| 7 |  |  | * The main difference between this program and ranimate is that | 
| 8 |  |  | * ranimove is optimized for object motion, and includes a complete | 
| 9 |  |  | * blur simulation.  We also have a number of clever schemes | 
| 10 |  |  | * for optimizing the computation, allowing rendering time | 
| 11 |  |  | * per frame and noticeable difference threshold to be specified. | 
| 12 |  |  | * Parallel rendering uses multiple processors on the local host, | 
| 13 |  |  | * and network rendering is not directly supported.  (However, no | 
| 14 |  |  | * one says you can't run ranimove on other machines at the | 
| 15 |  |  | * same time; just be careful not to overlap frames.) | 
| 16 |  |  | * | 
| 17 |  |  | * See the ranimove(1) man page for further details. | 
| 18 |  |  | */ | 
| 19 |  |  |  | 
| 20 | greg | 3.2 | #include "copyright.h" | 
| 21 | greg | 3.1 |  | 
| 22 |  |  | #include "ray.h" | 
| 23 |  |  | #include "view.h" | 
| 24 |  |  | #include "vars.h" | 
| 25 |  |  | /* input variables (alphabetical by name) */ | 
| 26 |  |  | #define BASENAME        0               /* output image base name */ | 
| 27 |  |  | #define END             1               /* number of animation frames */ | 
| 28 |  |  | #define EXPOSURE        2               /* how to compute exposure */ | 
| 29 |  |  | #define HIGHQ           3               /* high quality setting */ | 
| 30 |  |  | #define LOWQ            4               /* low quality setting */ | 
| 31 |  |  | #define MBLUR           5               /* motion blur parameter */ | 
| 32 |  |  | #define MOVE            6               /* object movement */ | 
| 33 |  |  | #define OCONV           7               /* oconv options */ | 
| 34 |  |  | #define OCTREEF         8               /* octree file name */ | 
| 35 |  |  | #define RATE            9               /* frame rate (fps) */ | 
| 36 |  |  | #define RESOLUTION      10              /* desired final resolution */ | 
| 37 |  |  | #define RIF             11              /* rad input file */ | 
| 38 |  |  | #define VIEWFILE        12              /* animation frame views */ | 
| 39 |  |  |  | 
| 40 |  |  | #define NV_INIT         13              /* number of variables */ | 
| 41 |  |  |  | 
| 42 |  |  | #define VV_INIT { \ | 
| 43 |  |  | {"BASENAME",    3,      0,      NULL,   onevalue}, \ | 
| 44 |  |  | {"END",         3,      0,      NULL,   intvalue}, \ | 
| 45 |  |  | {"EXPOSURE",    3,      0,      NULL,   onevalue}, \ | 
| 46 |  |  | {"highq",       2,      0,      NULL,   catvalues}, \ | 
| 47 |  |  | {"lowq",        2,      0,      NULL,   catvalues}, \ | 
| 48 |  |  | {"MBLUR",       2,      0,      NULL,   fltvalue}, \ | 
| 49 |  |  | {"move",        2,      0,      NULL,   NULL}, \ | 
| 50 |  |  | {"oconv",       2,      0,      NULL,   catvalues}, \ | 
| 51 |  |  | {"OCTREE",      3,      0,      NULL,   onevalue}, \ | 
| 52 |  |  | {"RATE",        2,      0,      NULL,   fltvalue}, \ | 
| 53 |  |  | {"RESOLUTION",  3,      0,      NULL,   onevalue}, \ | 
| 54 |  |  | {"RIF",         3,      0,      NULL,   onevalue}, \ | 
| 55 |  |  | {"VIEWFILE",    2,      0,      NULL,   onevalue} \ | 
| 56 |  |  | } | 
| 57 |  |  |  | 
| 58 |  |  | struct ObjMove { | 
| 59 |  |  | int             parent;         /* parent object index */ | 
| 60 |  |  | char            name[64];       /* object name */ | 
| 61 |  |  | char            xf_file[128];   /* transform file name */ | 
| 62 |  |  | char            spec[512];      /* object file or command */ | 
| 63 |  |  | char            prio_file[128]; /* priority file name */ | 
| 64 |  |  | int             cfm;            /* current frame number */ | 
| 65 |  |  | char            xfs[512];       /* part transform arguments */ | 
| 66 |  |  | MAT4            xfm;            /* part transform matrix */ | 
| 67 |  |  | MAT4            cxfm;           /* combined transform matrix */ | 
| 68 |  |  | MAT4            bxfm;           /* transform to previous frame */ | 
| 69 |  |  | double          prio;           /* part priority */ | 
| 70 |  |  | double          cprio;          /* combined priority */ | 
| 71 |  |  | }; | 
| 72 |  |  |  | 
| 73 |  |  | extern int              silent;         /* run silently? */ | 
| 74 |  |  |  | 
| 75 |  |  | extern int              quickstart;     /* time initial frame as well? */ | 
| 76 |  |  |  | 
| 77 |  |  | extern int              nprocs;         /* number of rendering processes */ | 
| 78 |  |  |  | 
| 79 |  |  | extern int              rtperfrm;       /* seconds to spend per frame */ | 
| 80 |  |  |  | 
| 81 |  |  | extern double           ndthresh;       /* noticeable difference threshold */ | 
| 82 |  |  | extern int              ndtset;         /* did user set ndthresh? */ | 
| 83 |  |  |  | 
| 84 |  |  | extern int              fbeg;           /* starting frame */ | 
| 85 |  |  | extern int              fend;           /* ending frame */ | 
| 86 |  |  | extern int              fcur;           /* current frame being rendered */ | 
| 87 |  |  |  | 
| 88 |  |  | extern char             lorendoptf[];   /* LQ options file */ | 
| 89 |  |  | extern RAYPARAMS        lorendparams;   /* LQ rendering parameters */ | 
| 90 |  |  | extern char             hirendoptf[];   /* HQ options file */ | 
| 91 |  |  | extern RAYPARAMS        hirendparams;   /* HQ rendering parameters */ | 
| 92 |  |  | extern RAYPARAMS        *curparams;     /* current parameter settings */ | 
| 93 |  |  | extern int              twolevels;      /* low and high quality differ */ | 
| 94 |  |  |  | 
| 95 |  |  | extern double   mblur;                  /* vflt(MBLUR) */ | 
| 96 |  |  | extern double   rate;                   /* vflt(RATE) */ | 
| 97 |  |  |  | 
| 98 |  |  | extern char             objtmpf[];      /* object temporary file */ | 
| 99 |  |  |  | 
| 100 |  |  | extern struct ObjMove   *obj_move;      /* object movements */ | 
| 101 |  |  |  | 
| 102 |  |  | extern int              haveprio;       /* high-level saliency specified */ | 
| 103 |  |  |  | 
| 104 |  |  | extern int              gargc;          /* global argc for printargs */ | 
| 105 |  |  | extern char             **gargv;        /* global argv for printargs */ | 
| 106 |  |  |  | 
| 107 |  |  | VIEW    *getview(); | 
| 108 |  |  | int     countviews(); | 
| 109 |  |  | int     getmove(); | 
| 110 |  |  | char    *getexp(), *getoctspec(), *getobjname(), *getxf(); | 
| 111 |  |  | double  expspec_val(), obj_prio(); | 
| 112 |  |  | void    setdefaults(), setmove(), animate(), getradfile(), setrendparams(); | 
| 113 |  |  | void    init_frame(), filter_frame(), send_frame(), free_frame(); | 
| 114 |  |  | int     refine_frame(); | 
| 115 |  |  | double  getTime(); | 
| 116 |  |  |  | 
| 117 |  |  | /************************************************************************* | 
| 118 |  |  | * Frame rendering stuff (defined in ranimove1.c and ranimove2.c) | 
| 119 |  |  | */ | 
| 120 |  |  | /* enumerated accuracy map values */ | 
| 121 |  |  | #define ANOVAL          0       /* unevaluated pixel */ | 
| 122 |  |  | #define ALOWQ           1       /* single low-quality sample */ | 
| 123 |  |  | #define AHIGHQ          2       /* single high-quality sample */ | 
| 124 |  |  | #define AMIN            3       /* start of error lookup table */ | 
| 125 |  |  | #define ADISTANT        255     /* ray went off to infinity */ | 
| 126 |  |  |  | 
| 127 |  |  | extern double   acctab[256];    /* accuracy value table */ | 
| 128 |  |  |  | 
| 129 |  |  | extern int      hres, vres;     /* frame resolution (fcur) */ | 
| 130 |  |  | extern double   pixaspect;      /* pixel aspect ratio */ | 
| 131 |  |  |  | 
| 132 |  |  | extern VIEW     vw;             /* view for this frame */ | 
| 133 |  |  | extern COLOR    *cbuffer;       /* color at each pixel */ | 
| 134 |  |  | extern float    *zbuffer;       /* depth at each pixel */ | 
| 135 |  |  | extern OBJECT   *obuffer;       /* object id at each pixel */ | 
| 136 |  |  | extern short    *xmbuffer;      /* x motion at each pixel */ | 
| 137 |  |  | extern short    *ymbuffer;      /* y motion at each pixel */ | 
| 138 |  |  | extern BYTE     *abuffer;       /* accuracy at each pixel */ | 
| 139 |  |  | extern BYTE     *sbuffer;       /* sample count per pixel */ | 
| 140 |  |  |  | 
| 141 |  |  | extern VIEW     vwprev;         /* last frame's view */ | 
| 142 |  |  | extern COLOR    *cprev;         /* last frame colors */ | 
| 143 |  |  | extern float    *zprev;         /* last frame depth */ | 
| 144 |  |  | extern OBJECT   *oprev;         /* last frame objects */ | 
| 145 |  |  | extern BYTE     *aprev;         /* last frame accuracy */ | 
| 146 |  |  |  | 
| 147 |  |  | extern float    *cerrmap;       /* conspicuous error map */ | 
| 148 |  |  | extern int      cerrzero;       /* is all of cerrmap zero? */ | 
| 149 |  |  | extern COLOR    *val2map;       /* value-squared map for variance */ | 
| 150 |  |  |  | 
| 151 |  |  | extern double   frm_stop;       /* when to stop rendering this frame */ | 
| 152 |  |  |  | 
| 153 |  |  | extern double   hlsmax;         /* maximum high-level saliency */ | 
| 154 |  |  |  | 
| 155 |  |  | #define CSF_SMN         (1./0.82)       /* 1/avg_tracking_efficacy */ | 
| 156 |  |  |  | 
| 157 |  |  | #define outbuffer       cprev   /* used to hold final output */ | 
| 158 |  |  | #define wbuffer         zprev   /* used for final filtering */ | 
| 159 |  |  |  | 
| 160 |  |  | #define fndx(x,y)       ((y)*hres + (x)) | 
| 161 |  |  |  | 
| 162 |  |  | #define MO_UNK          -32768  /* unknown motion value */ | 
| 163 |  |  |  | 
| 164 |  |  | #define FOV_DEG         1.0     /* foveal radius (degrees) */ | 
| 165 |  |  |  | 
| 166 |  |  | #define LOG_E1          (-0.0233)       /* ln(0.977) */ | 
| 167 |  |  | #define errorf(i)       exp(LOG_E1*((i)-AMIN)) | 
| 168 |  |  | #define errori(e)       (int)(log(e)*(1./LOG_E1) + (AMIN+.5)) | 
| 169 |  |  |  | 
| 170 |  |  | #define NSAMPOK         5       /* samples enough for error estimation */ | 
| 171 |  |  |  | 
| 172 |  |  | #define NPINTERP        4       /* number of pixels to interpolate */ | 
| 173 |  |  |  | 
| 174 |  |  | #define ATIDIFF         7       /* error difference for time extrapolation */ | 
| 175 |  |  |  | 
| 176 |  |  | void    write_map(), sample_pos(), comp_frame_error(), conspicuity(); | 
| 177 |  |  | int     getclosest(), getambcolor(), refine_first(); | 
| 178 |  |  | double  sample_wt(), estimaterr(), comperr(); |