ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_func.c
Revision: 2.7
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.6: +7 -5 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_func.c,v 2.6 2003/03/05 16:16:53 greg Exp $";
3 #endif
4 /*
5 * t_func.c - routine for procedural textures.
6 */
7
8 #include "copyright.h"
9
10 #include "ray.h"
11 #include "func.h"
12 #include "rtotypes.h"
13
14 /*
15 * A procedural texture perturbs the surface normal
16 * at the point of intersection with an object. It has
17 * the form:
18 *
19 * modifier texfunc name
20 * 4+ xvarname yvarname zvarname filename xf
21 * 0
22 * n A1 A2 ..
23 *
24 * Filename is the name of the file where the variable definitions
25 * can be found. The list of real arguments can be accessed by
26 * definitions in the file. The xf is a transformation to get
27 * from the original coordinates to the current coordinates.
28 */
29
30
31 extern int
32 t_func( /* compute texture for ray */
33 register OBJREC *m,
34 register RAY *r
35 )
36 {
37 FVECT disp;
38 double d;
39 register MFUNC *mf;
40 register int i;
41
42 if (m->oargs.nsargs < 4)
43 objerror(m, USER, "bad # arguments");
44 mf = getfunc(m, 3, 0x7, 1);
45 setfunc(m, r);
46 errno = 0;
47 for (i = 0; i < 3; i++) {
48 disp[i] = evalue(mf->ep[i]);
49 if (errno == EDOM || errno == ERANGE) {
50 objerror(m, WARNING, "compute error");
51 return(0);
52 }
53 }
54 if (mf->f != &unitxf)
55 multv3(disp, disp, mf->f->xfm);
56 if (r->rox != NULL) {
57 multv3(disp, disp, r->rox->f.xfm);
58 d = 1.0 / (mf->f->sca * r->rox->f.sca);
59 } else
60 d = 1.0 / mf->f->sca;
61 for (i = 0; i < 3; i++)
62 r->pert[i] += disp[i] * d;
63 return(0);
64 }