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

Comparing ray/src/rt/rv2.c (file contents):
Revision 2.38 by greg, Sat Feb 22 02:07:29 2003 UTC vs.
Revision 2.44 by greg, Tue Jan 18 00:33:16 2005 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *  External symbols declared in rpaint.h
8   */
9  
10 < /* ====================================================================
11 < * The Radiance Software License, Version 1.0
12 < *
13 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
14 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
15 < *
16 < * Redistribution and use in source and binary forms, with or without
17 < * modification, are permitted provided that the following conditions
18 < * are met:
19 < *
20 < * 1. Redistributions of source code must retain the above copyright
21 < *         notice, this list of conditions and the following disclaimer.
22 < *
23 < * 2. Redistributions in binary form must reproduce the above copyright
24 < *       notice, this list of conditions and the following disclaimer in
25 < *       the documentation and/or other materials provided with the
26 < *       distribution.
27 < *
28 < * 3. The end-user documentation included with the redistribution,
29 < *           if any, must include the following acknowledgment:
30 < *             "This product includes Radiance software
31 < *                 (http://radsite.lbl.gov/)
32 < *                 developed by the Lawrence Berkeley National Laboratory
33 < *               (http://www.lbl.gov/)."
34 < *       Alternately, this acknowledgment may appear in the software itself,
35 < *       if and wherever such third-party acknowledgments normally appear.
36 < *
37 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
38 < *       and "The Regents of the University of California" must
39 < *       not be used to endorse or promote products derived from this
40 < *       software without prior written permission. For written
41 < *       permission, please contact [email protected].
42 < *
43 < * 5. Products derived from this software may not be called "Radiance",
44 < *       nor may "Radiance" appear in their name, without prior written
45 < *       permission of Lawrence Berkeley National Laboratory.
46 < *
47 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
48 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
51 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
54 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 < * SUCH DAMAGE.
59 < * ====================================================================
60 < *
61 < * This software consists of voluntary contributions made by many
62 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
63 < * information on Lawrence Berkeley National Laboratory, please see
64 < * <http://www.lbl.gov/>.
65 < */
10 > #include "copyright.h"
11  
12 < #include  "ray.h"
12 > #include  <ctype.h>
13 > #include  <string.h>
14  
15 + #include  "platform.h"
16 + #include  "ray.h"
17 + #include  "ambient.h"
18   #include  "otypes.h"
70
19   #include  "rpaint.h"
20  
73 #include  <ctype.h>
74
21   extern int  psample;                    /* pixel sample size */
22   extern double  maxdiff;                 /* max. sample difference */
23  
# Line 89 | Line 35 | extern char  *progname;
35   extern char  *octname;
36  
37  
38 < void
39 < getframe(s)                             /* get a new frame */
40 < char  *s;
38 > extern void
39 > getframe(                               /* get a new frame */
40 >        char  *s
41 > )
42   {
43          if (getrect(s, &pframe) < 0)
44                  return;
# Line 99 | Line 46 | char  *s;
46   }
47  
48  
49 < void
50 < getrepaint(s)                           /* get area and repaint */
51 < char  *s;
49 > extern void
50 > getrepaint(                             /* get area and repaint */
51 >        char  *s
52 > )
53   {
54          RECT  box;
55  
# Line 111 | Line 59 | char  *s;
59   }
60  
61  
62 < void
63 < getview(s)                              /* get/show view parameters */
64 < char  *s;
62 > extern void
63 > getview(                                /* get/show view parameters */
64 >        char  *s
65 > )
66   {
67          FILE  *fp;
68          char  buf[128];
69          char  *fname;
70          int  change = 0;
71 <        VIEW  nv;
71 >        VIEW  nv = ourview;
72  
73          while (isspace(*s))
74                  s++;
75          if (*s == '-') {                        /* command line parameters */
127                copystruct(&nv, &ourview);
76                  if (sscanview(&nv, s))
77                          newview(&nv);
78                  else
# Line 152 | Line 100 | char  *s;
100          if (buf[0] && buf[0] != ourview.type) {
101                  nv.type = buf[0];
102                  change++;
103 <        } else
156 <                nv.type = ourview.type;
103 >        }
104          sprintf(buf, "view point (%.6g %.6g %.6g): ",
105                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
106          (*dev->comout)(buf);
# Line 161 | Line 108 | char  *s;
108          if (buf[0] == CTRL('C')) return;
109          if (sscanvec(buf, nv.vp))
110                  change++;
164        else
165                VCOPY(nv.vp, ourview.vp);
111          sprintf(buf, "view direction (%.6g %.6g %.6g): ",
112                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
113          (*dev->comout)(buf);
# Line 170 | Line 115 | char  *s;
115          if (buf[0] == CTRL('C')) return;
116          if (sscanvec(buf, nv.vdir))
117                  change++;
173        else
174                VCOPY(nv.vdir, ourview.vdir);
118          sprintf(buf, "view up (%.6g %.6g %.6g): ",
119                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
120          (*dev->comout)(buf);
# Line 179 | Line 122 | char  *s;
122          if (buf[0] == CTRL('C')) return;
123          if (sscanvec(buf, nv.vup))
124                  change++;
182        else
183                VCOPY(nv.vup, ourview.vup);
125          sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
126                          ourview.horiz, ourview.vert);
127          (*dev->comout)(buf);
# Line 188 | Line 129 | char  *s;
129          if (buf[0] == CTRL('C')) return;
130          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
131                  change++;
191        else {
192                nv.horiz = ourview.horiz; nv.vert = ourview.vert;
193        }
132          sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ",
133                          ourview.vfore, ourview.vaft);
134          (*dev->comout)(buf);
# Line 198 | Line 136 | char  *s;
136          if (buf[0] == CTRL('C')) return;
137          if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2)
138                  change++;
201        else {
202                nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
203        }
139          sprintf(buf, "view shift and lift (%.6g %.6g): ",
140                          ourview.hoff, ourview.voff);
141          (*dev->comout)(buf);
# Line 208 | Line 143 | char  *s;
143          if (buf[0] == CTRL('C')) return;
144          if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
145                  change++;
211        else {
212                nv.hoff = ourview.hoff; nv.voff = ourview.voff;
213        }
146          if (change)
147                  newview(&nv);
148   }
149  
150  
151 < void
152 < lastview(s)                             /* return to a previous view */
153 < char  *s;
151 > extern void
152 > lastview(                               /* return to a previous view */
153 >        char  *s
154 > )
155   {
156          char  buf[128];
157          char  *fname;
# Line 226 | Line 159 | char  *s;
159          VIEW  nv;
160  
161          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
162 <                copystruct(&nv, &stdview);
162 >                nv = stdview;
163                  if ((fname = getpath(buf, "", R_OK)) == NULL ||
164                                  (success = viewfile(fname, &nv, NULL)) == -1) {
165                          sprintf(errmsg, "cannot open \"%s\"", buf);
# Line 243 | Line 176 | char  *s;
176                  error(COMMAND, "no previous view");
177                  return;
178          }
179 <        copystruct(&nv, &ourview);
180 <        copystruct(&ourview, &oldview);
181 <        copystruct(&oldview, &nv);
179 >        nv = ourview;
180 >        ourview = oldview;
181 >        oldview = nv;
182          newimage();
183   }
184  
185  
186 < void
187 < saveview(s)                             /* save view to rad file */
188 < char  *s;
186 > extern void
187 > saveview(                               /* save view to rad file */
188 >        char  *s
189 > )
190   {
191          char  view[64];
192          char  *fname;
# Line 287 | Line 221 | char  *s;
221   }
222  
223  
224 < void
225 < loadview(s)                             /* load view from rad file */
226 < char  *s;
224 > extern void
225 > loadview(                               /* load view from rad file */
226 >        char  *s
227 > )
228   {
229          char  buf[512];
230          char  *fname;
# Line 320 | Line 255 | char  *s;
255          buf[0] = '\0';
256          fgets(buf, sizeof(buf), fp);
257          pclose(fp);
258 <        copystruct(&nv, &stdview);
258 >        nv = stdview;
259          if (!sscanview(&nv, buf)) {
260                  error(COMMAND, "rad error -- no such view?");
261                  return;
# Line 329 | Line 264 | char  *s;
264   }
265  
266  
267 < void
268 < getaim(s)                               /* aim camera */
269 < char  *s;
267 > extern void
268 > getaim(                         /* aim camera */
269 >        char  *s
270 > )
271   {
272 +        VIEW  nv = ourview;
273          double  zfact;
337        VIEW  nv;
274  
275          if (getinterest(s, 1, nv.vdir, &zfact) < 0)
276                  return;
341        nv.type = ourview.type;
342        VCOPY(nv.vp, ourview.vp);
343        VCOPY(nv.vup, ourview.vup);
344        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
345        nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
346        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
277          zoomview(&nv, zfact);
278          newview(&nv);
279   }
280  
281  
282 < void
283 < getmove(s)                              /* move camera */
284 < char  *s;
282 > extern void
283 > getmove(                                /* move camera */
284 >        char  *s
285 > )
286   {
287          FVECT  vc;
288          double  mag;
# Line 362 | Line 293 | char  *s;
293   }
294  
295  
296 < void
297 < getrotate(s)                            /* rotate camera */
298 < char  *s;
296 > extern void
297 > getrotate(                              /* rotate camera */
298 >        char  *s
299 > )
300   {
301 <        VIEW  nv;
301 >        VIEW  nv = ourview;
302          FVECT  v1;
303          double  angle, elev, zfact;
304          
# Line 375 | Line 307 | char  *s;
307                  error(COMMAND, "missing angle");
308                  return;
309          }
378        nv.type = ourview.type;
379        VCOPY(nv.vp, ourview.vp);
380        VCOPY(nv.vup, ourview.vup);
381        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
382        nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
310          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
311          if (elev != 0.0) {
312                  fcross(v1, nv.vdir, ourview.vup);
313                  normalize(v1);
314                  spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
315          }
389        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
316          zoomview(&nv, zfact);
317          newview(&nv);
318   }
319  
320  
321 < void
322 < getpivot(s)                             /* pivot viewpoint */
323 < register char  *s;
321 > extern void
322 > getpivot(                               /* pivot viewpoint */
323 >        register char  *s
324 > )
325   {
326          FVECT  vc;
327          double  angle, elev, mag;
# Line 410 | Line 337 | register char  *s;
337   }
338  
339  
340 < void
341 < getexposure(s)                          /* get new exposure */
342 < char  *s;
340 > extern void
341 > getexposure(                            /* get new exposure */
342 >        char  *s
343 > )
344   {
345          char  buf[128];
346          register char  *cp;
# Line 478 | Line 406 | char  *s;
406  
407   typedef union {int i; double d; COLOR C;}       *MyUptr;
408  
409 < int
410 < getparam(str, dsc, typ, p)              /* get variable from user */
411 < char  *str, *dsc;
412 < int  typ;
413 < void  *p;
409 > extern int
410 > getparam(               /* get variable from user */
411 >        char  *str,
412 >        char  *dsc,
413 >        int  typ,
414 >        void  *p
415 > )
416   {
417          register MyUptr  ptr = (MyUptr)p;
418          int  i0;
# Line 519 | Line 449 | void  *p;
449                          (*dev->comout)(buf);
450                          (*dev->comin)(buf, NULL);
451                          if (buf[0] == '\0' ||
452 <                                        index("yY+1tTnN-0fF", buf[0]) == NULL)
452 >                                        strchr("yY+1tTnN-0fF", buf[0]) == NULL)
453                                  return(0);
454                  }
455 <                ptr->i = index("yY+1tT", buf[0]) != NULL;
455 >                ptr->i = strchr("yY+1tT", buf[0]) != NULL;
456                  return(1);
457          case 'C':                       /* color */
458                  if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
# Line 539 | Line 469 | void  *p;
469                  setcolor(ptr->C, d0, d1, d2);
470                  return(1);
471          }
472 +        return 0; /* nothing matched */
473   }
474  
475  
476 < void
477 < setparam(s)                             /* get/set program parameter */
478 < register char  *s;
476 > extern void
477 > setparam(                               /* get/set program parameter */
478 >        register char  *s
479 > )
480   {
481          char  buf[128];
482          
# Line 716 | Line 648 | badparam:
648   }
649  
650  
651 < void
651 > extern void
652   traceray(s)                             /* trace a single ray */
653   char  *s;
654   {
# Line 785 | Line 717 | char  *s;
717   }
718  
719  
720 < void
720 > extern void
721   writepict(s)                            /* write the picture to a file */
722   char  *s;
723   {
# Line 809 | Line 741 | char  *s;
741                  error(COMMAND, errmsg);
742                  return;
743          }
744 < #ifdef MSDOS
813 <        setmode(fileno(fp), O_BINARY);
814 < #endif
744 >        SET_FILE_BINARY(fp);
745          (*dev->comout)("writing \"");
746          (*dev->comout)(fname);
747          (*dev->comout)("\"...\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines