ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/p_func.c
Revision: 2.3
Committed: Wed Jan 12 16:46:50 1994 UTC (30 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +4 -2 lines
Log Message:
made mixtures work with materials

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(0);
56 }
57 scalecolor(r->pcol, bval);
58 return(0);
59 }
60
61
62 p_cfunc(m, r) /* compute color pattern */
63 OBJREC *m;
64 RAY *r;
65 {
66 COLOR cval;
67 register MFUNC *mf;
68
69 if (m->oargs.nsargs < 4)
70 objerror(m, USER, "bad # arguments");
71 mf = getfunc(m, 3, 0x7, 0);
72 setfunc(m, r);
73 errno = 0;
74 setcolor(cval, evalue(mf->ep[0]),
75 evalue(mf->ep[1]),
76 evalue(mf->ep[2]));
77 if (errno) {
78 objerror(m, WARNING, "compute error");
79 return(0);
80 }
81 multcolor(r->pcol, cval);
82 return(0);
83 }