ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/p_func.c
Revision: 2.7
Committed: Tue Mar 30 16:13:01 2004 UTC (20 years, 1 month ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.6: +12 -8 lines
Log Message:
Continued ANSIfication. There are only bits and pieces left now.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 schorsch 2.7 static const char RCSid[] = "$Id: p_func.c,v 2.6 2003/03/05 16:16:53 greg Exp $";
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 greg 2.2 #include "func.h"
12 schorsch 2.7 #include "rtotypes.h"
13 greg 2.2
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 schorsch 2.7 extern int
38     p_bfunc( /* compute brightness pattern */
39     OBJREC *m,
40     RAY *r
41     )
42 greg 1.1 {
43     double bval;
44 greg 2.2 register MFUNC *mf;
45 greg 1.1
46     if (m->oargs.nsargs < 2)
47     objerror(m, USER, "bad # arguments");
48 greg 2.2 mf = getfunc(m, 1, 0x1, 0);
49     setfunc(m, r);
50 greg 1.1 errno = 0;
51 greg 2.2 bval = evalue(mf->ep[0]);
52 greg 2.6 if (errno == EDOM || errno == ERANGE) {
53 greg 1.1 objerror(m, WARNING, "compute error");
54 greg 2.3 return(0);
55 greg 1.1 }
56     scalecolor(r->pcol, bval);
57 greg 2.3 return(0);
58 greg 1.1 }
59    
60    
61 schorsch 2.7 extern int
62     p_cfunc( /* compute color pattern */
63     OBJREC *m,
64     RAY *r
65     )
66 greg 1.1 {
67     COLOR cval;
68 greg 2.2 register MFUNC *mf;
69 greg 1.1
70     if (m->oargs.nsargs < 4)
71     objerror(m, USER, "bad # arguments");
72 greg 2.2 mf = getfunc(m, 3, 0x7, 0);
73     setfunc(m, r);
74 greg 1.1 errno = 0;
75 greg 2.2 setcolor(cval, evalue(mf->ep[0]),
76     evalue(mf->ep[1]),
77     evalue(mf->ep[2]));
78 greg 2.6 if (errno == EDOM || errno == ERANGE) {
79 greg 1.1 objerror(m, WARNING, "compute error");
80 greg 2.3 return(0);
81 greg 1.1 }
82     multcolor(r->pcol, cval);
83 greg 2.3 return(0);
84 greg 1.1 }