home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / pointlist / ptlPolylist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-12  |  1.7 KB  |  70 lines

  1. #include "ooglutil.h"
  2. #include "geom.h"
  3. #include "polylistP.h"
  4. #include "pointlistP.h"
  5.  
  6. void *polylist_PointList_get(int sel, Geom *geom, va_list args);
  7. void *polylist_PointList_fillin(int sel, Geom *geom, va_list args);
  8. void *polylist_PointList_set(int sel, Geom *geom, va_list args);
  9. void *polylist_PointList_length(int sel, Geom *geom, va_list args);
  10.  
  11. #define MAX_METHODS 4
  12.  
  13. static SpecFunc methods[] = {
  14.   "PointList_get", polylist_PointList_get,
  15.   "PointList_fillin", polylist_PointList_fillin,
  16.   "PointList_set", polylist_PointList_set,
  17.   "PointList_length", polylist_PointList_length
  18.   };
  19.  
  20. static char msg[] = "ptlPolylist.c";
  21.  
  22. ptlPolylist_init() {
  23.   pointlist_initspec(methods, MAX_METHODS, GeomClassLookup("polylist"));
  24. }
  25.  
  26.  
  27. void *polylist_PointList_get(int sel, Geom *geom, va_list args) {
  28.   PolyList *p = (PolyList *)geom;
  29.   HPoint3 *plist;
  30.   float **t;
  31.   
  32.   plist = OOGLNewNE(HPoint3, p->n_verts, msg);
  33.   t = va_arg(args, float **);
  34.   return GeomCall(GeomMethodSel("PointList_fillin"), geom, t, 0, plist);
  35. }
  36.  
  37.  
  38. void *polylist_PointList_fillin(int sel, Geom *geom, va_list args) {
  39.   int i;
  40.   PolyList *p = (PolyList *)geom;
  41.   float **t;
  42.   HPoint3 *plist;
  43.  
  44.   t = va_arg(args, float **);
  45.   va_arg(args, int);
  46.   plist = va_arg(args, HPoint3 *);
  47.  
  48.   for (i = 0; i < p->n_verts; i++)
  49.     HPt3Transform(t, &p->vl[i].pt, &plist[i]);
  50.  
  51.   return((void *)plist);
  52. }
  53.  
  54. void *polylist_PointList_set(int sel, Geom *geom, va_list args) {
  55.   int i;
  56.   PolyList *p = (PolyList *)geom;
  57.   HPoint3 *plist;
  58.  
  59.   va_arg(args, int);
  60.   plist = va_arg(args, HPoint3 *);
  61.   for (i = 0; i < p->n_verts; i++) HPt3Copy(&plist[i], &p->vl[i].pt);
  62.   return((void *)p);
  63. }
  64.  
  65.  
  66. void *polylist_PointList_length(int sel, Geom *geom, va_list args) {
  67.   PolyList *p = (PolyList *)geom;
  68.   return((void *)p->n_verts);
  69. }
  70.