1 |
< |
/* Copyright (c) 1989 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1990 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
31 |
|
* to get from the original coordinates to the current coordinates. |
32 |
|
*/ |
33 |
|
|
34 |
– |
typedef struct { |
35 |
– |
struct { |
36 |
– |
double sca; /* scale factor */ |
37 |
– |
double xfm[4][4]; /* transformation matrix */ |
38 |
– |
} fore, back; |
39 |
– |
} XFORM; |
34 |
|
|
41 |
– |
|
35 |
|
t_data(m, r) /* interpolate texture data */ |
36 |
|
register OBJREC *m; |
37 |
|
RAY *r; |
41 |
|
int nv; |
42 |
|
FVECT dval, disp; |
43 |
|
double pt[MAXDIM]; |
44 |
+ |
double d; |
45 |
|
DATARRAY *dp; |
46 |
< |
register XFORM *mxf; |
46 |
> |
register FULLXF *mxf; |
47 |
|
register char **sa; |
48 |
|
register int i; |
49 |
|
|
54 |
|
for (i = 7; i < m->oargs.nsargs && sa[i][0] != '-'; i++) |
55 |
|
; |
56 |
|
nv = i-7; |
57 |
< |
if ((mxf = (XFORM *)m->os) == NULL) { |
58 |
< |
mxf = (XFORM *)malloc(sizeof(XFORM)); |
57 |
> |
if ((mxf = (FULLXF *)m->os) == NULL) { |
58 |
> |
mxf = (FULLXF *)malloc(sizeof(FULLXF)); |
59 |
|
if (mxf == NULL) |
60 |
|
goto memerr; |
61 |
< |
mxf->fore.sca = 1.0; |
68 |
< |
setident4(mxf->fore.xfm); |
69 |
< |
if (xf(mxf->fore.xfm, &mxf->fore.sca, |
70 |
< |
m->oargs.nsargs-i, sa+i) != m->oargs.nsargs-i) |
61 |
> |
if (fullxf(mxf, m->oargs.nsargs-i, sa+i) != m->oargs.nsargs-i) |
62 |
|
objerror(m, USER, "bad transform"); |
63 |
< |
if (mxf->fore.sca < 0.0) |
64 |
< |
mxf->fore.sca = -mxf->fore.sca; |
65 |
< |
mxf->back.sca = 1.0; |
66 |
< |
setident4(mxf->back.xfm); |
76 |
< |
invxf(mxf->back.xfm, &mxf->back.sca, |
77 |
< |
m->oargs.nsargs-i, sa+i); |
78 |
< |
if (mxf->back.sca < 0.0) |
79 |
< |
mxf->back.sca = -mxf->back.sca; |
63 |
> |
if (mxf->f.sca < 0.0) |
64 |
> |
mxf->f.sca = -mxf->f.sca; |
65 |
> |
if (mxf->b.sca < 0.0) |
66 |
> |
mxf->b.sca = -mxf->b.sca; |
67 |
|
m->os = (char *)mxf; |
68 |
|
} |
69 |
|
|
70 |
< |
setmap(m, r, mxf->back.xfm, mxf->back.sca); |
70 |
> |
setmap(m, r, &mxf->b); |
71 |
|
|
72 |
|
if (nv > MAXDIM) |
73 |
|
goto dimerr; |
90 |
|
if (errno) |
91 |
|
goto computerr; |
92 |
|
|
93 |
+ |
multv3(disp, disp, mxf->f.xfm); |
94 |
+ |
if (r->rox != NULL) { |
95 |
+ |
multv3(disp, disp, r->rox->f.xfm); |
96 |
+ |
d = 1.0 / (mxf->f.sca * r->rox->f.sca); |
97 |
+ |
} else |
98 |
+ |
d = 1.0 / mxf->f.sca; |
99 |
|
for (i = 0; i < 3; i++) |
100 |
< |
r->pert[i] += ( disp[0]*mxf->fore.xfm[0][i] + |
108 |
< |
disp[1]*mxf->fore.xfm[1][i] + |
109 |
< |
disp[2]*mxf->fore.xfm[2][i] ) |
110 |
< |
/ mxf->fore.sca; |
100 |
> |
r->pert[i] += disp[i] * d; |
101 |
|
return; |
102 |
|
dimerr: |
103 |
|
objerror(m, USER, "dimension error"); |