home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / POLYLINE.H < prev    next >
C/C++ Source or Header  |  1996-07-10  |  2KB  |  72 lines

  1. #ifndef _POLYLINE_H
  2. #define _POLYLINE_H
  3. struct PolyPoint {
  4.     int x, y, z;
  5. };
  6. typedef int PointID;
  7. struct PolyLine {
  8.     PointID p1, p2;
  9.     void *id;
  10. };
  11. struct Poly {
  12.     PointID *point;
  13.     int minx, miny, minz, maxx, maxy, maxz;
  14.     int points;
  15.     void *id;
  16. };
  17.  
  18. #define POLYALLOCUNIT 256
  19. class PolyData {
  20. public:
  21.     PolyPoint *point;
  22.     int points, allocpoints;
  23.  
  24.     PolyLine *line;
  25.     int lines, alloclines;
  26.  
  27.     Poly *poly;
  28.     int polys, allocpolys;
  29.  
  30.     PointID *pointbuf;
  31.     int pointbufs, allocpointbufs;
  32.  
  33.     int ScreenWidth, ScreenHeight;
  34.  
  35.     PolyData(int ps, int ls, int pls, int pps) {
  36.         point = new PolyPoint[allocpoints = ps];
  37.         line = new PolyLine[alloclines = ls];
  38.         poly = new Poly[allocpolys = pls];
  39.         pointbuf = new PointID[allocpointbufs = pps];
  40.         points = lines = polys = pointbufs = 0;
  41.         ScreenWidth = ScreenHeight = 0;
  42.     }
  43.     ~PolyData() {
  44.         delete [] point;
  45.         delete [] line;
  46.         delete [] poly;
  47.         delete [] pointbuf;
  48.     }
  49.     void Init(void) {
  50.         points = lines = polys = pointbufs = 0;
  51.     }
  52.     void Init(int w, int h) {
  53.         points = lines = polys = pointbufs = 0;
  54.         ScreenWidth = w;
  55.         ScreenHeight = h;
  56.     }
  57.     PointID AddPoint(int x, int y, int z);
  58.     void RemovePoint(PointID pid);
  59.     void AddLine(PointID p1, PointID p2, void *id = NULL);
  60.     int AddPolyClip(int *ps, int offset);
  61.     void AddPoly(int *points, int offset, void *id = NULL);
  62.     void AddPolyInv(int *points, int offset, void *id = NULL);
  63.     void ConvertLines(void);
  64.     int IsOutside(PointID p, PointID p1, PointID p2);
  65.     double TriangleCrossRate(PointID l1, PointID l2, PointID p1, PointID p2, PointID p3);
  66.     int TriangleIsFront(PointID p, PointID p1, PointID p2, PointID p3);
  67.     double CrossRate(PointID l1, PointID l2, PointID p1, PointID p2);
  68.     void ConvertLine(Poly *cpoly);
  69.  
  70.  
  71. };
  72. #endif