ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/func.c
(Generate patch)

Comparing ray/src/rt/func.c (file contents):
Revision 1.5 by greg, Wed Apr 19 21:36:11 1989 UTC vs.
Revision 1.11 by greg, Wed Dec 12 21:57:50 1990 UTC

# Line 38 | Line 38 | double  sca;
38  
39          if (initfile != NULL) {
40                  loadfunc(initfile);
41 <                scompile(NULL, "Dx=$1;Dy=$2;Dz=$3;");
42 <                scompile(NULL, "Nx=$4;Ny=$5;Nz=$6;");
43 <                scompile(NULL, "Px=$7;Py=$8;Pz=$9;");
44 <                scompile(NULL, "T=$10;Rdot=$11;");
41 >                scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0);
42 >                scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0);
43 >                scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0);
44 >                scompile("T=$10;Rdot=$11;", NULL, 0);
45 >                scompile("S=$12;Tx=$13;Ty=$14;Tz=$15;", NULL, 0);
46 >                scompile("Ix=$16;Iy=$17;Iz=$18;", NULL, 0);
47 >                scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0);
48 >                scompile("Kx=$22;Ky=$23;Kz=$24;", NULL, 0);
49                  funset("arg", 1, l_arg);
50                  funset("noise3", 3, l_noise3);
51                  funset("noise3a", 3, l_noise3a);
# Line 75 | Line 79 | RAY  *r;
79                  mxf = (XF *)malloc(sizeof(XF));
80                  if (mxf == NULL)
81                          goto memerr;
78                mxf->sca = 1.0;
79                setident4(mxf->xfm);
82                  if (invxf(mxf->xfm, &mxf->sca, n, sa) != n)
83                          objerror(m, USER, "bad transform");
84                  if (mxf->sca < 0.0)
# Line 87 | Line 89 | RAY  *r;
89          return;
90   memerr:
91          error(SYSTEM, "out of memory in setfunc");
90 #undef  mxf
92   }
93  
94  
# Line 97 | Line 98 | char  *fname;
98          extern char  *libpath;          /* library search path */
99          char  *ffname;
100  
101 <        if ((ffname = getpath(fname, libpath)) == NULL) {
101 >        if ((ffname = getpath(fname, libpath, R_OK)) == NULL) {
102                  sprintf(errmsg, "cannot find function file \"%s\"", fname);
103                  error(USER, errmsg);
104          }
# Line 128 | Line 129 | double
129   chanvalue(n)                    /* return channel n to calcomp */
130   register int  n;
131   {
132 <        double  res;
132 >        double  sum;
133          register RAY  *r;
134  
135 <        n--;                                    /* for convenience */
135 >        if (--n < 0)
136 >                goto badchan;
137  
138 <        if (n < 0 || n > 10)
137 <                error(USER, "illegal channel number");
138 >        if (n < 3)                      /* ray direction */
139  
140 <        if (n == 9) {                           /* distance */
140 >                return( (       fray->rdir[0]*fxf.xfm[0][n] +
141 >                                fray->rdir[1]*fxf.xfm[1][n] +
142 >                                fray->rdir[2]*fxf.xfm[2][n]     )
143 >                         / fxf.sca );
144  
145 <                res = fray->rot;
142 <                for (r = fray->parent; r != NULL; r = r->parent)
143 <                        res += r->rot;
144 <                res *= fxf.sca;
145 >        if (n < 6)                      /* surface normal */
146  
147 <        } else if (n == 10) {                   /* dot product */
147 >                return( (       fray->ron[0]*fxf.xfm[0][n-3] +
148 >                                fray->ron[1]*fxf.xfm[1][n-3] +
149 >                                fray->ron[2]*fxf.xfm[2][n-3]    )
150 >                         / fxf.sca );
151  
152 <                res = fray->rod;
152 >        if (n < 9)                      /* intersection */
153  
154 <        } else if (n < 3) {                     /* ray direction */
155 <                        res = ( fray->rdir[0]*fxf.xfm[0][n] +
156 <                                        fray->rdir[1]*fxf.xfm[1][n] +
157 <                                        fray->rdir[2]*fxf.xfm[2][n]     )
158 <                                 / fxf.sca ;
159 <        } else if (n < 6) {                     /* surface normal */
160 <                        res = ( fray->ron[0]*fxf.xfm[0][n-3] +
161 <                                        fray->ron[1]*fxf.xfm[1][n-3] +
162 <                                        fray->ron[2]*fxf.xfm[2][n-3]    )
163 <                                 / fxf.sca ;
164 <        } else {                                /* intersection */
165 <                        res =   fray->rop[0]*fxf.xfm[0][n-6] +
162 <                                        fray->rop[1]*fxf.xfm[1][n-6] +
163 <                                        fray->rop[2]*fxf.xfm[2][n-6] +
164 <                                                     fxf.xfm[3][n-6] ;
154 >                return( fray->rop[0]*fxf.xfm[0][n-6] +
155 >                                fray->rop[1]*fxf.xfm[1][n-6] +
156 >                                fray->rop[2]*fxf.xfm[2][n-6] +
157 >                                             fxf.xfm[3][n-6] );
158 >
159 >        if (n == 9) {                   /* distance */
160 >
161 >                sum = fray->rot;
162 >                for (r = fray->parent; r != NULL; r = r->parent)
163 >                        sum += r->rot;
164 >                return(sum * fxf.sca);
165 >
166          }
167 +        if (n == 10)                    /* dot product */
168 +                return(fray->rod);
169  
170 <        return(res);
170 >        if (n == 11)                    /* scale */
171 >                return(fxf.sca);
172 >
173 >        if (n < 15)                     /* origin */
174 >                return(fxf.xfm[3][n-12]);
175 >
176 >        if (n < 18)                     /* i unit vector */
177 >                return(fxf.xfm[0][n-15] / fxf.sca);
178 >
179 >        if (n < 21)                     /* j unit vector */
180 >                return(fxf.xfm[1][n-15] / fxf.sca);
181 >
182 >        if (n < 24)                     /* k unit vector */
183 >                return(fxf.xfm[2][n-21] / fxf.sca);
184 > badchan:
185 >        error(USER, "illegal channel number");
186   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines