ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_data.c
Revision: 2.3
Committed: Tue Jun 30 19:10:38 1992 UTC (31 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +9 -11 lines
Log Message:
fixed bug associated with -DSMLFLT option

File Contents

# User Rev Content
1 greg 2.3 /* Copyright (c) 1992 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_data.c - routine for stored textures
9     *
10     * 6/4/86
11     */
12    
13     #include "ray.h"
14    
15     #include "data.h"
16    
17 greg 2.2 #include "func.h"
18    
19 greg 1.1 /*
20     * A stored texture is specified as follows:
21     *
22     * modifier texdata name
23     * 8+ xfunc yfunc zfunc xdfname ydfname zdfname vfname v0 v1 .. xf
24     * 0
25     * n A1 A2 .. An
26     *
27     * Vfname 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 dfnames are the data file
30     * names. The dimensions of the data files and the number
31     * of variables must match. The funcs take three arguments to produce
32     * interpolated values from the file. The xf is a transformation
33     * to get from the original coordinates to the current coordinates.
34     */
35    
36    
37     t_data(m, r) /* interpolate texture data */
38     register OBJREC *m;
39     RAY *r;
40     {
41     int nv;
42 greg 2.3 FVECT disp;
43     double dval[3], pt[MAXDIM];
44 greg 1.4 double d;
45 greg 1.1 DATARRAY *dp;
46 greg 2.2 register MFUNC *mf;
47 greg 1.1 register int i;
48    
49     if (m->oargs.nsargs < 8)
50     objerror(m, USER, "bad # arguments");
51 greg 2.2 dp = getdata(m->oargs.sarg[3]);
52     i = (1 << (nv = dp->nd)) - 1;
53     mf = getfunc(m, 6, i<<7, 1);
54     setfunc(m, r);
55     errno = 0;
56 greg 2.3 for (i = 0; i < nv; i++)
57 greg 2.2 pt[i] = evalue(mf->ep[i]);
58 greg 2.3 if (errno)
59     goto computerr;
60 greg 2.2 dval[0] = datavalue(dp, pt);
61     for (i = 1; i < 3; i++) {
62     dp = getdata(m->oargs.sarg[i+3]);
63 greg 1.1 if (dp->nd != nv)
64 greg 2.2 objerror(m, USER, "dimension error");
65 greg 1.1 dval[i] = datavalue(dp, pt);
66     }
67     errno = 0;
68 greg 2.3 for (i = 0; i < 3; i++)
69 greg 2.2 disp[i] = funvalue(m->oargs.sarg[i], 3, dval);
70 greg 2.3 if (errno)
71     goto computerr;
72 greg 2.2 if (mf->f != &unitxf)
73     multv3(disp, disp, mf->f->xfm);
74 greg 1.6 if (r->rox != NULL) {
75     multv3(disp, disp, r->rox->f.xfm);
76 greg 2.2 d = 1.0 / (mf->f->sca * r->rox->f.sca);
77 greg 1.6 } else
78 greg 2.2 d = 1.0 / mf->f->sca;
79 greg 1.1 for (i = 0; i < 3; i++)
80 greg 1.4 r->pert[i] += disp[i] * d;
81 greg 1.1 return;
82     computerr:
83     objerror(m, WARNING, "compute error");
84     return;
85     }