ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/p_func.c
Revision: 2.5
Committed: Tue Feb 25 02:47:23 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.4: +1 -56 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

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