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

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: t_data.c,v 2.10 2012/06/09 07:16:47 greg Exp $";
3 #endif
4 /*
5 * t_data.c - routine for stored textures
6 */
7
8 #include "copyright.h"
9
10 #include "ray.h"
11 #include "data.h"
12 #include "func.h"
13 #include "rtotypes.h"
14
15 /*
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 int
34 t_data( /* interpolate texture data */
35 OBJREC *m,
36 RAY *r
37 )
38 {
39 int nv;
40 FVECT disp;
41 double dval[3], pt[MAXDIM];
42 double d;
43 DATARRAY *dp;
44 MFUNC *mf;
45 int i;
46
47 if (m->oargs.nsargs < 8)
48 objerror(m, USER, "bad # arguments");
49 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 for (i = 0; i < nv; i++)
55 pt[i] = evalue(mf->ep[i]);
56 if (errno == EDOM || errno == ERANGE)
57 goto computerr;
58 dval[0] = datavalue(dp, pt);
59 for (i = 1; i < 3; i++) {
60 dp = getdata(m->oargs.sarg[i+3]);
61 if (dp->nd != nv)
62 objerror(m, USER, "dimension error");
63 dval[i] = datavalue(dp, pt);
64 }
65 errno = 0;
66 for (i = 0; i < 3; i++)
67 disp[i] = funvalue(m->oargs.sarg[i], 3, dval);
68 if (errno == EDOM || errno == ERANGE)
69 goto computerr;
70 if (mf->fxp != &unitxf)
71 multv3(disp, disp, mf->fxp->xfm);
72 if (r->rox != NULL) {
73 multv3(disp, disp, r->rox->f.xfm);
74 d = 1.0 / (mf->fxp->sca * r->rox->f.sca);
75 } else
76 d = 1.0 / mf->fxp->sca;
77 VSUM(r->pert, r->pert, disp, d);
78 return(0);
79 computerr:
80 objerror(m, WARNING, "compute error");
81 return(0);
82 }