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 |
|
|
* p_func.c - routine for procedural patterns. |
9 |
|
|
* |
10 |
|
|
* 4/8/86 |
11 |
|
|
*/ |
12 |
|
|
|
13 |
|
|
#include "ray.h" |
14 |
|
|
|
15 |
greg |
2.2 |
#include "func.h" |
16 |
|
|
|
17 |
greg |
1.1 |
/* |
18 |
|
|
* A procedural pattern can either be a brightness or a |
19 |
|
|
* color function. A brightness function is given as: |
20 |
|
|
* |
21 |
|
|
* modifier brightfunc name |
22 |
|
|
* 2+ bvarname filename xf |
23 |
|
|
* 0 |
24 |
|
|
* n A1 A2 .. |
25 |
|
|
* |
26 |
|
|
* A color function is given as: |
27 |
|
|
* |
28 |
|
|
* modifier colorfunc name |
29 |
|
|
* 4+ rvarname gvarname bvarname filename xf |
30 |
|
|
* 0 |
31 |
|
|
* n A1 A2 .. |
32 |
|
|
* |
33 |
|
|
* Filename is the name of the file where the variable definitions |
34 |
|
|
* can be found. The list of real arguments can be accessed by |
35 |
|
|
* definitions in the file. The xf is a transformation |
36 |
|
|
* to get from the original coordinates to the current coordinates. |
37 |
|
|
*/ |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
p_bfunc(m, r) /* compute brightness pattern */ |
41 |
greg |
2.2 |
OBJREC *m; |
42 |
greg |
1.1 |
RAY *r; |
43 |
|
|
{ |
44 |
|
|
double bval; |
45 |
greg |
2.2 |
register MFUNC *mf; |
46 |
greg |
1.1 |
|
47 |
|
|
if (m->oargs.nsargs < 2) |
48 |
|
|
objerror(m, USER, "bad # arguments"); |
49 |
greg |
2.2 |
mf = getfunc(m, 1, 0x1, 0); |
50 |
|
|
setfunc(m, r); |
51 |
greg |
1.1 |
errno = 0; |
52 |
greg |
2.2 |
bval = evalue(mf->ep[0]); |
53 |
greg |
1.1 |
if (errno) { |
54 |
|
|
objerror(m, WARNING, "compute error"); |
55 |
|
|
return; |
56 |
|
|
} |
57 |
|
|
scalecolor(r->pcol, bval); |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
|
61 |
|
|
p_cfunc(m, r) /* compute color pattern */ |
62 |
greg |
2.2 |
OBJREC *m; |
63 |
greg |
1.1 |
RAY *r; |
64 |
|
|
{ |
65 |
|
|
COLOR cval; |
66 |
greg |
2.2 |
register MFUNC *mf; |
67 |
greg |
1.1 |
|
68 |
|
|
if (m->oargs.nsargs < 4) |
69 |
|
|
objerror(m, USER, "bad # arguments"); |
70 |
greg |
2.2 |
mf = getfunc(m, 3, 0x7, 0); |
71 |
|
|
setfunc(m, r); |
72 |
greg |
1.1 |
errno = 0; |
73 |
greg |
2.2 |
setcolor(cval, evalue(mf->ep[0]), |
74 |
|
|
evalue(mf->ep[1]), |
75 |
|
|
evalue(mf->ep[2])); |
76 |
greg |
1.1 |
if (errno) { |
77 |
|
|
objerror(m, WARNING, "compute error"); |
78 |
|
|
return; |
79 |
|
|
} |
80 |
|
|
multcolor(r->pcol, cval); |
81 |
|
|
} |