ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/p_func.c
Revision: 2.2
Committed: Mon Nov 25 09:50:57 1991 UTC (32 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +15 -23 lines
Log Message:
changed function file calls to allow expressions instead of just vars

File Contents

# Content
1 /* Copyright (c) 1991 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * p_func.c - routine for procedural patterns.
9 *
10 * 4/8/86
11 */
12
13 #include "ray.h"
14
15 #include "func.h"
16
17 /*
18 * A procedural pattern can either be a brightness or a
19 * color function. A brightness function is given as:
20 *
21 * modifier brightfunc name
22 * 2+ bvarname filename xf
23 * 0
24 * n A1 A2 ..
25 *
26 * A color function is given as:
27 *
28 * modifier colorfunc name
29 * 4+ rvarname gvarname bvarname filename xf
30 * 0
31 * n A1 A2 ..
32 *
33 * Filename is the name of the file where the variable definitions
34 * can be found. The list of real arguments can be accessed by
35 * definitions in the file. The xf is a transformation
36 * to get from the original coordinates to the current coordinates.
37 */
38
39
40 p_bfunc(m, r) /* compute brightness pattern */
41 OBJREC *m;
42 RAY *r;
43 {
44 double bval;
45 register MFUNC *mf;
46
47 if (m->oargs.nsargs < 2)
48 objerror(m, USER, "bad # arguments");
49 mf = getfunc(m, 1, 0x1, 0);
50 setfunc(m, r);
51 errno = 0;
52 bval = evalue(mf->ep[0]);
53 if (errno) {
54 objerror(m, WARNING, "compute error");
55 return;
56 }
57 scalecolor(r->pcol, bval);
58 }
59
60
61 p_cfunc(m, r) /* compute color pattern */
62 OBJREC *m;
63 RAY *r;
64 {
65 COLOR cval;
66 register MFUNC *mf;
67
68 if (m->oargs.nsargs < 4)
69 objerror(m, USER, "bad # arguments");
70 mf = getfunc(m, 3, 0x7, 0);
71 setfunc(m, r);
72 errno = 0;
73 setcolor(cval, evalue(mf->ep[0]),
74 evalue(mf->ep[1]),
75 evalue(mf->ep[2]));
76 if (errno) {
77 objerror(m, WARNING, "compute error");
78 return;
79 }
80 multcolor(r->pcol, cval);
81 }