ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_func.c
Revision: 2.3
Committed: Wed Jan 12 16:46:54 1994 UTC (30 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +2 -1 lines
Log Message:
made mixtures work with materials

File Contents

# Content
1 /* Copyright (c) 1991 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * t_func.c - routine for procedural textures.
9 *
10 * 4/8/86
11 */
12
13 #include "ray.h"
14
15 #include "func.h"
16
17 /*
18 * A procedural texture perturbs the surface normal
19 * at the point of intersection with an object. It has
20 * the form:
21 *
22 * modifier texfunc name
23 * 4+ xvarname yvarname zvarname filename xf
24 * 0
25 * n A1 A2 ..
26 *
27 * Filename is the name of the file where the variable definitions
28 * can be found. The list of real arguments can be accessed by
29 * definitions in the file. The xf is a transformation to get
30 * from the original coordinates to the current coordinates.
31 */
32
33
34 t_func(m, r) /* compute texture for ray */
35 register OBJREC *m;
36 register RAY *r;
37 {
38 FVECT disp;
39 double d;
40 register MFUNC *mf;
41 register int i;
42
43 if (m->oargs.nsargs < 4)
44 objerror(m, USER, "bad # arguments");
45 mf = getfunc(m, 3, 0x7, 1);
46 setfunc(m, r);
47 errno = 0;
48 for (i = 0; i < 3; i++) {
49 disp[i] = evalue(mf->ep[i]);
50 if (errno) {
51 objerror(m, WARNING, "compute error");
52 return(0);
53 }
54 }
55 if (mf->f != &unitxf)
56 multv3(disp, disp, mf->f->xfm);
57 if (r->rox != NULL) {
58 multv3(disp, disp, r->rox->f.xfm);
59 d = 1.0 / (mf->f->sca * r->rox->f.sca);
60 } else
61 d = 1.0 / mf->f->sca;
62 for (i = 0; i < 3; i++)
63 r->pert[i] += disp[i] * d;
64 return(0);
65 }