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

# User Rev Content
1 greg 2.2 /* Copyright (c) 1991 Regents of the University of California */
2 greg 1.1
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 greg 2.2 #include "func.h"
16    
17 greg 1.1 /*
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 greg 2.2 OBJREC *m;
42 greg 1.1 RAY *r;
43     {
44     double bval;
45 greg 2.2 register MFUNC *mf;
46 greg 1.1
47     if (m->oargs.nsargs < 2)
48     objerror(m, USER, "bad # arguments");
49 greg 2.2 mf = getfunc(m, 1, 0x1, 0);
50     setfunc(m, r);
51 greg 1.1 errno = 0;
52 greg 2.2 bval = evalue(mf->ep[0]);
53 greg 1.1 if (errno) {
54     objerror(m, WARNING, "compute error");
55 greg 2.3 return(0);
56 greg 1.1 }
57     scalecolor(r->pcol, bval);
58 greg 2.3 return(0);
59 greg 1.1 }
60    
61    
62     p_cfunc(m, r) /* compute color pattern */
63 greg 2.2 OBJREC *m;
64 greg 1.1 RAY *r;
65     {
66     COLOR cval;
67 greg 2.2 register MFUNC *mf;
68 greg 1.1
69     if (m->oargs.nsargs < 4)
70     objerror(m, USER, "bad # arguments");
71 greg 2.2 mf = getfunc(m, 3, 0x7, 0);
72     setfunc(m, r);
73 greg 1.1 errno = 0;
74 greg 2.2 setcolor(cval, evalue(mf->ep[0]),
75     evalue(mf->ep[1]),
76     evalue(mf->ep[2]));
77 greg 1.1 if (errno) {
78     objerror(m, WARNING, "compute error");
79 greg 2.3 return(0);
80 greg 1.1 }
81     multcolor(r->pcol, cval);
82 greg 2.3 return(0);
83 greg 1.1 }