ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_data.c
Revision: 2.2
Committed: Mon Nov 25 09:50:54 1991 UTC (32 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +26 -47 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_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     FVECT dval, disp;
43     double 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     for (i = 0; i < nv; i++) {
57     pt[i] = evalue(mf->ep[i]);
58     if (errno)
59     goto computerr;
60 greg 1.1 }
61 greg 2.2 dval[0] = datavalue(dp, pt);
62     for (i = 1; i < 3; i++) {
63     dp = getdata(m->oargs.sarg[i+3]);
64 greg 1.1 if (dp->nd != nv)
65 greg 2.2 objerror(m, USER, "dimension error");
66 greg 1.1 dval[i] = datavalue(dp, pt);
67     }
68     errno = 0;
69 greg 2.2 for (i = 0; i < 3; i++) {
70     disp[i] = funvalue(m->oargs.sarg[i], 3, dval);
71     if (errno)
72     goto computerr;
73     }
74     if (mf->f != &unitxf)
75     multv3(disp, disp, mf->f->xfm);
76 greg 1.6 if (r->rox != NULL) {
77     multv3(disp, disp, r->rox->f.xfm);
78 greg 2.2 d = 1.0 / (mf->f->sca * r->rox->f.sca);
79 greg 1.6 } else
80 greg 2.2 d = 1.0 / mf->f->sca;
81 greg 1.1 for (i = 0; i < 3; i++)
82 greg 1.4 r->pert[i] += disp[i] * d;
83 greg 1.1 return;
84     computerr:
85     objerror(m, WARNING, "compute error");
86     return;
87     }