ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_data.c
Revision: 2.11
Committed: Tue Jul 8 18:25:00 2014 UTC (9 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R2P1, rad5R3
Changes since 2.10: +5 -5 lines
Log Message:
Eliminated unnecessary "extern" and "register" modifiers

File Contents

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