ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_func.c
Revision: 2.6
Committed: Tue Feb 25 02:47:22 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.5: +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.5 static const char RCSid[] = "$Id$";
3 greg 1.1 #endif
4     /*
5     * mx_func.c - routine for mixture functions.
6 greg 2.5 */
7    
8 greg 2.6 #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 mixture function is specified:
16     *
17     * modifier mixfunc name
18     * 4+ foremod backmod varname vfname xf
19     * 0
20     * n A1 A2 ..
21     *
22     * Vfname is the name of the file where the variable definition
23     * can be found. The list of real arguments can be accessed by
24     * definitions in the file. The xf is a transformation
25     * to get from the original coordinates to the current coordinates.
26     */
27    
28    
29     mx_func(m, r) /* compute mixture function */
30     register OBJREC *m;
31     RAY *r;
32     {
33 gwlarson 2.4 OBJECT obj;
34 greg 1.1 register int i;
35     double coef;
36     OBJECT mod[2];
37 greg 2.2 register MFUNC *mf;
38 greg 1.1
39     if (m->oargs.nsargs < 4)
40     objerror(m, USER, "bad # arguments");
41 gwlarson 2.4 obj = objndx(m);
42 greg 1.1 for (i = 0; i < 2; i++)
43 greg 2.2 if (!strcmp(m->oargs.sarg[i], VOIDID))
44 greg 1.1 mod[i] = OVOID;
45 gwlarson 2.4 else if ((mod[i] = lastmod(obj, m->oargs.sarg[i])) == OVOID) {
46 greg 2.2 sprintf(errmsg, "undefined modifier \"%s\"",
47     m->oargs.sarg[i]);
48 greg 1.1 objerror(m, USER, errmsg);
49     }
50 greg 2.2 mf = getfunc(m, 3, 0x4, 0);
51     setfunc(m, r);
52 greg 1.1 errno = 0;
53 greg 2.2 coef = evalue(mf->ep[0]);
54 greg 1.1 if (errno) {
55     objerror(m, WARNING, "compute error");
56 greg 2.3 return(0);
57 greg 1.1 }
58 greg 2.3 if (raymixture(r, mod[0], mod[1], coef)) {
59     if (m->omod != OVOID)
60     objerror(m, USER, "inappropriate modifier");
61     return(1);
62     }
63     return(0);
64 greg 1.1 }