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

Comparing ray/src/common/image.c (file contents):
Revision 2.6 by greg, Sat Dec 5 16:23:37 1992 UTC vs.
Revision 2.7 by greg, Tue Dec 20 20:15:04 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 28 | Line 28 | register VIEW  *v;
28          static char  ill_horiz[] = "illegal horizontal view size";
29          static char  ill_vert[] = "illegal vertical view size";
30          
31 +        if (v->vfore < -FTINY || v->vaft < -FTINY ||
32 +                        (v->vaft > FTINY && v->vaft <= v->vfore))
33 +                return("illegal fore/aft clipping plane");
34 +
35          if (normalize(v->vdir) == 0.0)          /* normalize direction */
36                  return("zero view direction");
37  
# Line 107 | Line 111 | int  *xp, *yp;                 /* x and y resolution in (or out if *
111   }
112  
113  
114 + double
115   viewray(orig, direc, v, x, y)           /* compute ray origin and direction */
116   FVECT  orig, direc;
117   register VIEW  *v;
# Line 119 | Line 124 | double  x, y;
124  
125          switch(v->type) {
126          case VT_PAR:                    /* parallel view */
127 <                orig[0] = v->vp[0] + x*v->hvec[0] + y*v->vvec[0];
128 <                orig[1] = v->vp[1] + x*v->hvec[1] + y*v->vvec[1];
129 <                orig[2] = v->vp[2] + x*v->hvec[2] + y*v->vvec[2];
127 >                orig[0] = v->vp[0] + v->vfore*v->vdir[0]
128 >                                + x*v->hvec[0] + y*v->vvec[0];
129 >                orig[1] = v->vp[1] + v->vfore*v->vdir[1]
130 >                                + x*v->hvec[1] + y*v->vvec[1];
131 >                orig[2] = v->vp[2] + v->vfore*v->vdir[2]
132 >                                + x*v->hvec[2] + y*v->vvec[2];
133                  VCOPY(direc, v->vdir);
134 <                return(0);
134 >                return(v->vaft - v->vfore);
135          case VT_PER:                    /* perspective view */
128                VCOPY(orig, v->vp);
136                  direc[0] = v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
137                  direc[1] = v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
138                  direc[2] = v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
139 <                normalize(direc);
140 <                return(0);
139 >                orig[0] = v->vp[0] + v->vfore*direc[0];
140 >                orig[1] = v->vp[1] + v->vfore*direc[1];
141 >                orig[2] = v->vp[2] + v->vfore*direc[2];
142 >                d = normalize(direc);
143 >                return((v->vaft - v->vfore)*d);
144          case VT_HEM:                    /* hemispherical fisheye */
145                  z = 1.0 - x*x*v->hn2 - y*y*v->vn2;
146                  if (z < 0.0)
147 <                        return(-1);
147 >                        return(-1.0);
148                  z = sqrt(z);
139                VCOPY(orig, v->vp);
149                  direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
150                  direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
151                  direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
152 <                return(0);
152 >                orig[0] = v->vp[0] + v->vfore*direc[0];
153 >                orig[1] = v->vp[1] + v->vfore*direc[1];
154 >                orig[2] = v->vp[2] + v->vfore*direc[2];
155 >                return(v->vaft - v->vfore);
156          case VT_ANG:                    /* angular fisheye */
157                  x *= v->horiz/180.0;
158                  y *= v->vert/180.0;
159                  d = x*x + y*y;
160                  if (d > 1.0)
161 <                        return(-1);
150 <                VCOPY(orig, v->vp);
161 >                        return(-1.0);
162                  d = sqrt(d);
163                  z = cos(PI*d);
164                  d = d <= FTINY ? PI : sqrt(1 - z*z)/d;
# Line 156 | Line 167 | double  x, y;
167                  direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
168                  direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
169                  direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
170 <                return(0);
170 >                orig[0] = v->vp[0] + v->vfore*direc[0];
171 >                orig[1] = v->vp[1] + v->vfore*direc[1];
172 >                orig[2] = v->vp[2] + v->vfore*direc[2];
173 >                return(v->vaft - v->vfore);
174          }
175 <        return(-1);
175 >        return(-1.0);
176   }
177  
178  
# Line 176 | Line 190 | FVECT  p;
190  
191          switch (v->type) {
192          case VT_PAR:                    /* parallel view */
193 <                ip[2] = DOT(disp,v->vdir);
193 >                ip[2] = DOT(disp,v->vdir) - v->vfore;
194                  break;
195          case VT_PER:                    /* perspective view */
196                  d = DOT(disp,v->vdir);
# Line 184 | Line 198 | FVECT  p;
198                  if (d < 0.0) {          /* fold pyramid */
199                          ip[2] = -ip[2];
200                          d = -d;
201 <                } else if (d > FTINY) {
201 >                }
202 >                if (d > FTINY) {
203                          d = 1.0/d;
204                          disp[0] *= d;
205                          disp[1] *= d;
206                          disp[2] *= d;
207                  }
208 +                ip[2] *= (1.0 - v->vfore*d);
209                  break;
210          case VT_HEM:                    /* hemispherical fisheye */
211                  d = normalize(disp);
# Line 197 | Line 213 | FVECT  p;
213                          ip[2] = -d;
214                  else
215                          ip[2] = d;
216 +                ip[2] -= v->vfore;
217                  break;
218          case VT_ANG:                    /* angular fisheye */
219                  ip[0] = 0.5 - v->hoff;
220                  ip[1] = 0.5 - v->voff;
221 <                ip[2] = normalize(disp);
221 >                ip[2] = normalize(disp) - v->vfore;
222                  d = DOT(disp,v->vdir);
223                  if (d >= 1.0-FTINY)
224                          return;
225                  if (d <= -(1.0-FTINY)) {
226 <                        ip[1] += 180.0/v->horiz;
227 <                        ip[2] += 180.0/v->vert;
226 >                        ip[0] += 180.0/v->horiz;
227 >                        ip[1] += 180.0/v->vert;
228                          return;
229                  }
230                  d = acos(d)/PI / sqrt(1.0 - d*d);
# Line 310 | Line 327 | register char  *av[];
327                  check(3,"f");
328                  v->vert = atof(av[1]);
329                  return(1);
330 +        case 'o':                       /* fore clipping plane */
331 +                check(3,"f");
332 +                v->vfore = atof(av[1]);
333 +                return(1);
334 +        case 'a':                       /* aft clipping plane */
335 +                check(3,"f");
336 +                v->vaft = atof(av[1]);
337 +                return(1);
338          case 's':                       /* shift */
339                  check(3,"f");
340                  v->hoff = atof(av[1]);
# Line 366 | Line 391 | FILE  *fp;
391          fprintf(fp, " -vd %.6g %.6g %.6g", vp->vdir[0], vp->vdir[1], vp->vdir[2]);
392          fprintf(fp, " -vu %.6g %.6g %.6g", vp->vup[0], vp->vup[1], vp->vup[2]);
393          fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert);
394 +        fprintf(fp, " -vo %.6g -va %.6g", vp->vfore, vp->vaft);
395          fprintf(fp, " -vs %.6g -vl %.6g", vp->hoff, vp->voff);
396   }
397  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines