1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* p_func.c - routine for procedural patterns. |
9 |
– |
* |
10 |
– |
* 4/8/86 |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
|
#include "ray.h" |
11 |
|
|
12 |
+ |
#include "func.h" |
13 |
+ |
|
14 |
|
/* |
15 |
|
* A procedural pattern can either be a brightness or a |
16 |
|
* color function. A brightness function is given as: |
35 |
|
|
36 |
|
|
37 |
|
p_bfunc(m, r) /* compute brightness pattern */ |
38 |
< |
register OBJREC *m; |
38 |
> |
OBJREC *m; |
39 |
|
RAY *r; |
40 |
|
{ |
42 |
– |
extern double varvalue(); |
43 |
– |
extern int errno; |
41 |
|
double bval; |
42 |
< |
register char **sa; |
42 |
> |
register MFUNC *mf; |
43 |
|
|
47 |
– |
setfunc(m, r); |
48 |
– |
|
49 |
– |
sa = m->oargs.sarg; |
50 |
– |
|
44 |
|
if (m->oargs.nsargs < 2) |
45 |
|
objerror(m, USER, "bad # arguments"); |
46 |
< |
funcfile(sa[1]); |
46 |
> |
mf = getfunc(m, 1, 0x1, 0); |
47 |
> |
setfunc(m, r); |
48 |
|
errno = 0; |
49 |
< |
bval = varvalue(sa[0]); |
50 |
< |
if (errno) { |
49 |
> |
bval = evalue(mf->ep[0]); |
50 |
> |
if (errno == EDOM || errno == ERANGE) { |
51 |
|
objerror(m, WARNING, "compute error"); |
52 |
< |
return; |
52 |
> |
return(0); |
53 |
|
} |
54 |
|
scalecolor(r->pcol, bval); |
55 |
+ |
return(0); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
p_cfunc(m, r) /* compute color pattern */ |
60 |
< |
register OBJREC *m; |
60 |
> |
OBJREC *m; |
61 |
|
RAY *r; |
62 |
|
{ |
68 |
– |
extern double varvalue(); |
69 |
– |
extern int errno; |
63 |
|
COLOR cval; |
64 |
< |
register char **sa; |
64 |
> |
register MFUNC *mf; |
65 |
|
|
73 |
– |
setfunc(m, r); |
74 |
– |
|
75 |
– |
sa = m->oargs.sarg; |
76 |
– |
|
66 |
|
if (m->oargs.nsargs < 4) |
67 |
|
objerror(m, USER, "bad # arguments"); |
68 |
< |
funcfile(sa[3]); |
68 |
> |
mf = getfunc(m, 3, 0x7, 0); |
69 |
> |
setfunc(m, r); |
70 |
|
errno = 0; |
71 |
< |
setcolor(cval, varvalue(sa[0]), |
72 |
< |
varvalue(sa[1]), |
73 |
< |
varvalue(sa[2])); |
74 |
< |
if (errno) { |
71 |
> |
setcolor(cval, evalue(mf->ep[0]), |
72 |
> |
evalue(mf->ep[1]), |
73 |
> |
evalue(mf->ep[2])); |
74 |
> |
if (errno == EDOM || errno == ERANGE) { |
75 |
|
objerror(m, WARNING, "compute error"); |
76 |
< |
return; |
76 |
> |
return(0); |
77 |
|
} |
78 |
|
multcolor(r->pcol, cval); |
79 |
+ |
return(0); |
80 |
|
} |