ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_func.c
Revision: 2.2
Committed: Mon Nov 25 09:50:59 1991 UTC (32 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +16 -34 lines
Log Message:
changed function file calls to allow expressions instead of just vars

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     * t_func.c - routine for procedural textures.
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 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 greg 1.6 double d;
40 greg 2.2 register MFUNC *mf;
41 greg 1.1 register int i;
42    
43     if (m->oargs.nsargs < 4)
44     objerror(m, USER, "bad # arguments");
45 greg 2.2 mf = getfunc(m, 3, 0x7, 1);
46     setfunc(m, r);
47 greg 1.1 errno = 0;
48 greg 2.2 for (i = 0; i < 3; i++) {
49     disp[i] = evalue(mf->ep[i]);
50     if (errno) {
51     objerror(m, WARNING, "compute error");
52     return;
53     }
54 greg 1.1 }
55 greg 2.2 if (mf->f != &unitxf)
56     multv3(disp, disp, mf->f->xfm);
57 greg 1.8 if (r->rox != NULL) {
58     multv3(disp, disp, r->rox->f.xfm);
59 greg 2.2 d = 1.0 / (mf->f->sca * r->rox->f.sca);
60 greg 1.8 } else
61 greg 2.2 d = 1.0 / mf->f->sca;
62 greg 1.4 for (i = 0; i < 3; i++)
63 greg 1.6 r->pert[i] += disp[i] * d;
64 greg 1.1 }