ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/vwright.c
Revision: 2.10
Committed: Mon Mar 19 16:35:19 2018 UTC (4 years, 6 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad5R3, HEAD
Changes since 2.9: +2 -2 lines
Log Message:
Fixed usage message

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: vwright.c,v 2.9 2011/08/21 14:45:25 greg Exp $";
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 int
21 main(
22 int argc,
23 char *argv[]
24 )
25 {
26 char *err;
27 int gotview = 0;
28 FVECT hvn, vvn;
29 double dist;
30 int i;
31
32 progname = argv[0];
33 ++argv; --argc;
34 while (argc && argv[0][0] == '-' && argv[0][1] == 'v') {
35 int rv;
36 if (argc > 2 && argv[0][2] == 'f') {
37 rv = viewfile(argv[1], &vw, NULL);
38 if (rv <= 0) {
39 fprintf(stderr, "%s: %s file '%s'\n",
40 progname,
41 rv < 0 ? "cannot open view" :
42 "no view in", argv[1]);
43 exit(1);
44 }
45 ++gotview;
46 ++argv; --argc;
47 } else {
48 rv = getviewopt(&vw, argc, argv);
49 if (rv < 0) {
50 fprintf(stderr, "%s: bad view option at '%s'\n",
51 progname, argv[0]);
52 exit(1);
53 }
54 ++gotview;
55 argv += rv; argc -= rv;
56 }
57 ++argv; --argc;
58 }
59 if (argc != 1)
60 goto userr;
61 if (!gotview) {
62 gotview = viewfile(NULL, &vw, NULL);
63 if (gotview <= 0) {
64 fprintf(stderr, "%s: no view on standard input\n",
65 progname);
66 exit(1);
67 }
68 }
69 if ((err= setview(&vw)) != NULL) {
70 fprintf(stderr, "%s: %s\n", progname, err);
71 exit(1);
72 }
73 VCOPY(hvn, vw.hvec);
74 normalize(hvn);
75 VCOPY(vvn, vw.vvec);
76 normalize(vvn);
77 if (isalpha(argv[0][0])) { /* print out variables */
78 switch (vw.type) {
79 case VT_PER: i=1; break;
80 case VT_PAR: i=2; break;
81 case VT_ANG: i=3; break;
82 case VT_HEM: i=4; break;
83 case VT_CYL: i=5; break;
84 case VT_PLS: i=6; break;
85 default: i=0; break;
86 }
87 printf("%st:%d;", argv[0], i);
88 printf("%spx:%g;%spy:%g;%spz:%g;", argv[0], vw.vp[0],
89 argv[0], vw.vp[1], argv[0], vw.vp[2]);
90 printf("%sdx:%g;%sdy:%g;%sdz:%g;", argv[0], vw.vdir[0],
91 argv[0], vw.vdir[1], argv[0], vw.vdir[2]);
92 printf("%sd:%g;", argv[0], vw.vdist);
93 printf("%sux:%g;%suy:%g;%suz:%g;", argv[0], vw.vup[0],
94 argv[0], vw.vup[1], argv[0], vw.vup[2]);
95 printf("%sh:%g;%sv:%g;", argv[0], vw.horiz,
96 argv[0], vw.vert);
97 printf("%ss:%g;%sl:%g;%so:%g;%sa:%g;",
98 argv[0], vw.hoff, argv[0], vw.voff,
99 argv[0], vw.vfore, argv[0], vw.vaft);
100 printf("%shx:%g;%shy:%g;%shz:%g;%shn:%g;",
101 argv[0], hvn[0], argv[0], hvn[1],
102 argv[0], hvn[2], argv[0], sqrt(vw.hn2));
103 printf("%svx:%g;%svy:%g;%svz:%g;%svn:%g;\n",
104 argv[0], vvn[0], argv[0], vvn[1],
105 argv[0], vvn[2], argv[0], sqrt(vw.vn2));
106 exit(0);
107 }
108 if (!isflt(argv[0]))
109 goto userr;
110 dist = atof(argv[0]);
111 VSUM(vw.vp, vw.vp, hvn, dist);
112 fprintview(&vw, stdout);
113 fputc('\n', stdout);
114 exit(0);
115 userr:
116 fprintf(stderr, "Usage: %s [view options] {offset|name}\n", progname);
117 exit(1);
118 }