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

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.4 static const char RCSid[] = "$Id$";
3 greg 1.1 #endif
4     /*
5     * p_func.c - routine for procedural patterns.
6 greg 2.4 */
7    
8 greg 2.5 #include "copyright.h"
9 greg 1.1
10     #include "ray.h"
11    
12 greg 2.2 #include "func.h"
13    
14 greg 1.1 /*
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 greg 2.2 OBJREC *m;
39 greg 1.1 RAY *r;
40     {
41     double bval;
42 greg 2.2 register MFUNC *mf;
43 greg 1.1
44     if (m->oargs.nsargs < 2)
45     objerror(m, USER, "bad # arguments");
46 greg 2.2 mf = getfunc(m, 1, 0x1, 0);
47     setfunc(m, r);
48 greg 1.1 errno = 0;
49 greg 2.2 bval = evalue(mf->ep[0]);
50 greg 1.1 if (errno) {
51     objerror(m, WARNING, "compute error");
52 greg 2.3 return(0);
53 greg 1.1 }
54     scalecolor(r->pcol, bval);
55 greg 2.3 return(0);
56 greg 1.1 }
57    
58    
59     p_cfunc(m, r) /* compute color pattern */
60 greg 2.2 OBJREC *m;
61 greg 1.1 RAY *r;
62     {
63     COLOR cval;
64 greg 2.2 register MFUNC *mf;
65 greg 1.1
66     if (m->oargs.nsargs < 4)
67     objerror(m, USER, "bad # arguments");
68 greg 2.2 mf = getfunc(m, 3, 0x7, 0);
69     setfunc(m, r);
70 greg 1.1 errno = 0;
71 greg 2.2 setcolor(cval, evalue(mf->ep[0]),
72     evalue(mf->ep[1]),
73     evalue(mf->ep[2]));
74 greg 1.1 if (errno) {
75     objerror(m, WARNING, "compute error");
76 greg 2.3 return(0);
77 greg 1.1 }
78     multcolor(r->pcol, cval);
79 greg 2.3 return(0);
80 greg 1.1 }