ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/vwright.c
Revision: 2.4
Committed: Sat Feb 22 02:07:30 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.3: +1 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * Move a viewpoint the given distance to the right
6 */
7
8
9 #include "standard.h"
10
11 #include "view.h"
12
13 #include <ctype.h>
14
15 VIEW vw = STDVIEW;
16
17 char *progname;
18
19
20 main(argc, argv)
21 int argc;
22 char *argv[];
23 {
24 char linebuf[256];
25 char *err;
26 int gotview = 0;
27 FVECT hvn, vvn;
28 double dist;
29 register int i;
30
31 progname = argv[0];
32 if (argc != 2)
33 goto userr;
34 while (fgets(linebuf, sizeof(linebuf), stdin) != NULL) {
35 if (linebuf[0] == '\n')
36 break;
37 if (isview(linebuf) && sscanview(&vw, linebuf) > 0)
38 gotview++;
39 }
40 if (!gotview) {
41 fprintf(stderr, "%s: no view on standard input\n", progname);
42 exit(1);
43 }
44 if ((err= setview(&vw)) != NULL) {
45 fprintf(stderr, "%s: %s\n", progname, err);
46 exit(1);
47 }
48 VCOPY(hvn, vw.hvec);
49 normalize(hvn);
50 VCOPY(vvn, vw.vvec);
51 normalize(vvn);
52 if (isalpha(argv[1][0])) { /* print out variables */
53 switch (vw.type) {
54 case VT_PER: i=1; break;
55 case VT_PAR: i=2; break;
56 case VT_ANG: i=3; break;
57 case VT_HEM: i=4; break;
58 case VT_CYL: i=5; break;
59 default: i=0; break;
60 }
61 printf("%st:%d;", argv[1], i);
62 printf("%spx:%g;%spy:%g;%spz:%g;", argv[1], vw.vp[0],
63 argv[1], vw.vp[1], argv[1], vw.vp[2]);
64 printf("%sdx:%g;%sdy:%g;%sdz:%g;", argv[1], vw.vdir[0],
65 argv[1], vw.vdir[1], argv[1], vw.vdir[2]);
66 printf("%sux:%g;%suy:%g;%suz:%g;", argv[1], vw.vup[0],
67 argv[1], vw.vup[1], argv[1], vw.vup[2]);
68 printf("%sh:%g;%sv:%g;", argv[1], vw.horiz,
69 argv[1], vw.vert);
70 printf("%ss:%g;%sl:%g;%so:%g;%sa:%g;",
71 argv[1], vw.hoff, argv[1], vw.voff,
72 argv[1], vw.vfore, argv[1], vw.vaft);
73 printf("%shx:%g;%shy:%g;%shz:%g;%shn:%g;",
74 argv[1], hvn[0], argv[1], hvn[1],
75 argv[1], hvn[2], argv[1], sqrt(vw.hn2));
76 printf("%svx:%g;%svy:%g;%svz:%g;%svn:%g;\n",
77 argv[1], vvn[0], argv[1], vvn[1],
78 argv[1], vvn[2], argv[1], sqrt(vw.vn2));
79 exit(0);
80 }
81 if (!isflt(argv[1]))
82 goto userr;
83 dist = atof(argv[1]);
84 for (i = 0; i < 3; i++)
85 vw.vp[i] += dist*hvn[i];
86 fprintview(&vw, stdout);
87 putchar('\n');
88 exit(0);
89 userr:
90 fprintf(stderr, "Usage: %s {offset|name}\n", progname);
91 exit(1);
92 }