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

Comparing ray/src/common/rglsurf.c (file contents):
Revision 3.5 by greg, Tue Feb 25 02:47:22 2003 UTC vs.
Revision 3.9 by greg, Sun May 25 15:41:31 2003 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   * Convert Radiance -> OpenGL surfaces.
# Line 111 | Line 111 | newtess()                      /* allocate GLU tessellation object */
111   {
112          if ((gluto = gluNewTess()) == NULL)
113                  error(INTERNAL, "gluNewTess failed");
114 <        gluTessCallback(gluto, GLU_TESS_BEGIN, (_GLUfuncptr)glBegin);
115 <        gluTessCallback(gluto, GLU_TESS_VERTEX, (_GLUfuncptr)glVertex3dv);
114 >        gluTessCallback(gluto, GLU_TESS_BEGIN, glBegin);
115 >        gluTessCallback(gluto, GLU_TESS_VERTEX, glVertex3dv);
116          gluTessCallback(gluto, GLU_TESS_END, glEnd);
117          gluTessCallback(gluto, GLU_TESS_COMBINE, myCombine);
118          gluTessCallback(gluto, GLU_TESS_ERROR, glu_error);
# Line 142 | Line 142 | register OBJREC        *o;
142                  objerror(o, USER, "bad # real arguments");
143          area = polyarea(cent, norm, o->oargs.nfargs/3, (FVECT *)o->oargs.farg);
144          if (area <= FTINY)
145 <                return;
145 >                return(0);
146          if (dolights)                                   /* check for source */
147                  doflatsrc((MATREC *)o->os, cent, norm, area);
148          setmaterial((MATREC *)o->os, cent, 1);          /* set material */
# Line 177 | Line 177 | register OBJREC        *o;
177                                          (GLdouble)o->oargs.farg[3*i+1],
178                                          (GLdouble)o->oargs.farg[3*i+2]);
179          }
180 +        return(0);
181   }
182  
183  
# Line 207 | Line 208 | register OBJREC        *o;
208                  o->otype = o->otype==OBJ_SPHERE ? OBJ_BUBBLE : OBJ_SPHERE;
209                  o->oargs.farg[3] = -o->oargs.farg[3];
210          } else if (o->oargs.farg[3] <= FTINY)
211 <                return;
211 >                return(0);
212          if (dolights)
213                  dosphsrc((MATREC *)o->os, o->oargs.farg,
214                                  PI*o->oargs.farg[3]*o->oargs.farg[3]);
# Line 223 | Line 224 | register OBJREC        *o;
224                          (GLdouble)o->oargs.farg[2]);
225          gluSphere(gluqo, (GLdouble)o->oargs.farg[3], NSLICES, NSTACKS);
226          glPopMatrix();
227 +        return(0);
228   }
229  
230  
# Line 257 | Line 259 | register OBJREC *o;
259                  if (o->oargs.farg[7] < 0.)
260                          o->oargs.farg[7] = 0.;
261          }
262 +        h = sqrt(dist2(o->oargs.farg,o->oargs.farg+3));
263 +        if (h <= FTINY)
264 +                return;
265          cent[0] = .5*(o->oargs.farg[0] + o->oargs.farg[3]);
266          cent[1] = .5*(o->oargs.farg[1] + o->oargs.farg[4]);
267          cent[2] = .5*(o->oargs.farg[2] + o->oargs.farg[5]);
# Line 272 | Line 277 | register OBJREC *o;
277          glTranslated((GLdouble)o->oargs.farg[0], (GLdouble)o->oargs.farg[1],
278                          (GLdouble)o->oargs.farg[2]);
279                                          /* compute height & rotation angle */
275        h = sqrt(dist2(o->oargs.farg,o->oargs.farg+3));
276        if (h <= FTINY)
277                return;
280          x1 = o->oargs.farg[1] - o->oargs.farg[4];
281          y1 = o->oargs.farg[3] - o->oargs.farg[0];
282          /* z1 = 0; */
283 <        d = 180./PI * asin(sqrt(x1*x1 + y1*y1) / h);
283 >        d = x1*x1 + y1*y1;
284 >        if (d <= FTINY*FTINY)
285 >                x1 = 1.;
286 >        else
287 >                d = 180./PI * asin(sqrt(d) / h);
288          if (o->oargs.farg[5] < o->oargs.farg[2])
289                  d = 180. - d;
290          if (d > FTINY)
# Line 286 | Line 292 | register OBJREC *o;
292          gluCylinder(gluqo, o->oargs.farg[6], o->oargs.farg[iscyl ? 6 : 7],
293                          h, NSLICES, 1);
294          glPopMatrix();
295 +        return(0);
296   }
297  
298  
# Line 293 | Line 300 | int
300   o_ring(o)                       /* convert a ring */
301   register OBJREC *o;
302   {
303 <        double  x1, y1, d;
303 >        double  x1, y1, d, h;
304  
305          if (o->oargs.nfargs != 8)
306                  objerror(o, USER, "bad # real arguments");
# Line 308 | Line 315 | register OBJREC        *o;
315                  o->oargs.farg[6] = 0.;
316          if (o->oargs.farg[7] - o->oargs.farg[6] <= FTINY)
317                  return;
318 +        h = VLEN(o->oargs.farg+3);
319 +        if (h <= FTINY)
320 +                return;
321          if (dolights)
322                  doflatsrc((MATREC *)o->os, o->oargs.farg, o->oargs.farg+3,
323                                  PI*(o->oargs.farg[7]*o->oargs.farg[7] -
# Line 322 | Line 332 | register OBJREC        *o;
332          glTranslated((GLdouble)o->oargs.farg[0], (GLdouble)o->oargs.farg[1],
333                          (GLdouble)o->oargs.farg[2]);
334                                          /* compute rotation angle */
325        d = VLEN(o->oargs.farg+3);
326        if (d <= FTINY)
327                return;
335          x1 = -o->oargs.farg[4];
336          y1 = o->oargs.farg[3];
337          /* z1 = 0; */
338 <        d = 180./PI * asin(sqrt(x1*x1 + y1*y1) / d);
338 >        d = x1*x1 + y1*y1;
339 >        if (d <= FTINY*FTINY)
340 >                x1 = 1.;
341 >        else
342 >                d = 180./PI * asin(sqrt(d) / h);
343          if (o->oargs.farg[5] < 0.)
344                  d = 180. - d;
345          if (d > FTINY)
346                  glRotated(d, (GLdouble)x1, (GLdouble)y1, 0.);
347          gluDisk(gluqo, o->oargs.farg[6], o->oargs.farg[7], NSLICES, 1);
348          glPopMatrix();
349 +        return(0);
350   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines