1 |
< |
/* Copyright (c) 1990 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
15 |
|
#include "otypes.h" |
16 |
|
|
17 |
|
|
18 |
+ |
XF unitxf = { /* identity transform */ |
19 |
+ |
1.0, 0.0, 0.0, 0.0, |
20 |
+ |
0.0, 1.0, 0.0, 0.0, |
21 |
+ |
0.0, 0.0, 1.0, 0.0, |
22 |
+ |
0.0, 0.0, 0.0, 1.0, |
23 |
+ |
1.0 |
24 |
+ |
}; |
25 |
+ |
|
26 |
|
XF funcxf; /* current transformation */ |
27 |
|
static OBJREC *fobj = NULL; /* current function object */ |
28 |
|
static RAY *fray = NULL; /* current function ray */ |
33 |
|
register RAY *r; |
34 |
|
XF *bx; |
35 |
|
{ |
36 |
< |
extern double l_noise3(), l_noise3a(), l_noise3b(), l_noise3c(); |
29 |
< |
extern double l_hermite(), l_fnoise3(), l_arg(); |
36 |
> |
extern double l_arg(); |
37 |
|
extern long eclock; |
38 |
|
static char *initfile = "rayinit.cal"; |
32 |
– |
static long lastrno = -1; |
33 |
– |
/* check to see if already set */ |
34 |
– |
if (m == fobj && r->rno == lastrno) |
35 |
– |
return; |
39 |
|
/* initialize if first call */ |
40 |
|
if (initfile != NULL) { |
41 |
|
loadfunc(initfile); |
47 |
|
scompile("Ix=$16;Iy=$17;Iz=$18;", NULL, 0); |
48 |
|
scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0); |
49 |
|
scompile("Kx=$22;Ky=$23;Kz=$24;", NULL, 0); |
50 |
< |
funset("arg", 1, l_arg); |
51 |
< |
funset("noise3", 3, l_noise3); |
49 |
< |
funset("noise3a", 3, l_noise3a); |
50 |
< |
funset("noise3b", 3, l_noise3b); |
51 |
< |
funset("noise3c", 3, l_noise3c); |
52 |
< |
funset("hermite", 5, l_hermite); |
53 |
< |
funset("fnoise3", 3, l_fnoise3); |
50 |
> |
funset("arg", 1, '=', l_arg); |
51 |
> |
setnoisefuncs(); |
52 |
|
initfile = NULL; |
53 |
|
} |
54 |
|
fobj = m; |
55 |
|
fray = r; |
56 |
< |
lastrno = r->rno; |
57 |
< |
if (r->rox != NULL) { |
58 |
< |
funcxf.sca = r->rox->b.sca * bx->sca; |
59 |
< |
multmat4(funcxf.xfm, r->rox->b.xfm, bx->xfm); |
60 |
< |
} else |
56 |
> |
if (r->rox != NULL) |
57 |
> |
if (bx != &unitxf) { |
58 |
> |
funcxf.sca = r->rox->b.sca * bx->sca; |
59 |
> |
multmat4(funcxf.xfm, r->rox->b.xfm, bx->xfm); |
60 |
> |
} else |
61 |
> |
copystruct(&funcxf, &r->rox->b); |
62 |
> |
else |
63 |
|
copystruct(&funcxf, bx); |
64 |
|
eclock++; /* notify expression evaluator */ |
65 |
|
} |
78 |
|
for (n = m->oargs.nsargs, sa = m->oargs.sarg; |
79 |
|
n > 0 && **sa != '-'; n--, sa++) |
80 |
|
; |
81 |
< |
mxf = (XF *)malloc(sizeof(XF)); |
82 |
< |
if (mxf == NULL) |
83 |
< |
goto memerr; |
84 |
< |
if (invxf(mxf, n, sa) != n) |
85 |
< |
objerror(m, USER, "bad transform"); |
86 |
< |
if (mxf->sca < 0.0) |
87 |
< |
mxf->sca = -mxf->sca; |
81 |
> |
if (n == 0) |
82 |
> |
mxf = &unitxf; |
83 |
> |
else { |
84 |
> |
mxf = (XF *)malloc(sizeof(XF)); |
85 |
> |
if (mxf == NULL) |
86 |
> |
goto memerr; |
87 |
> |
if (invxf(mxf, n, sa) != n) |
88 |
> |
objerror(m, USER, "bad transform"); |
89 |
> |
if (mxf->sca < 0.0) |
90 |
> |
mxf->sca = -mxf->sca; |
91 |
> |
} |
92 |
|
m->os = (char *)mxf; |
93 |
|
} |
94 |
|
setmap(m, r, mxf); |