ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_data.c
Revision: 2.8
Committed: Tue Mar 30 16:13:01 2004 UTC (20 years ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.7: +7 -6 lines
Log Message:
Continued ANSIfication. There are only bits and pieces left now.

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: t_data.c,v 2.7 2003/03/05 16:16:53 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 extern int
34 t_data( /* interpolate texture data */
35 register 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 register MFUNC *mf;
45 register 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->f != &unitxf)
71 multv3(disp, disp, mf->f->xfm);
72 if (r->rox != NULL) {
73 multv3(disp, disp, r->rox->f.xfm);
74 d = 1.0 / (mf->f->sca * r->rox->f.sca);
75 } else
76 d = 1.0 / mf->f->sca;
77 for (i = 0; i < 3; i++)
78 r->pert[i] += disp[i] * d;
79 return(0);
80 computerr:
81 objerror(m, WARNING, "compute error");
82 return(0);
83 }