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 >
Wrap
C/C++ Source or Header
|
1996-07-10
|
2KB
|
72 lines
#ifndef _POLYLINE_H
#define _POLYLINE_H
struct PolyPoint {
int x, y, z;
};
typedef int PointID;
struct PolyLine {
PointID p1, p2;
void *id;
};
struct Poly {
PointID *point;
int minx, miny, minz, maxx, maxy, maxz;
int points;
void *id;
};
#define POLYALLOCUNIT 256
class PolyData {
public:
PolyPoint *point;
int points, allocpoints;
PolyLine *line;
int lines, alloclines;
Poly *poly;
int polys, allocpolys;
PointID *pointbuf;
int pointbufs, allocpointbufs;
int ScreenWidth, ScreenHeight;
PolyData(int ps, int ls, int pls, int pps) {
point = new PolyPoint[allocpoints = ps];
line = new PolyLine[alloclines = ls];
poly = new Poly[allocpolys = pls];
pointbuf = new PointID[allocpointbufs = pps];
points = lines = polys = pointbufs = 0;
ScreenWidth = ScreenHeight = 0;
}
~PolyData() {
delete [] point;
delete [] line;
delete [] poly;
delete [] pointbuf;
}
void Init(void) {
points = lines = polys = pointbufs = 0;
}
void Init(int w, int h) {
points = lines = polys = pointbufs = 0;
ScreenWidth = w;
ScreenHeight = h;
}
PointID AddPoint(int x, int y, int z);
void RemovePoint(PointID pid);
void AddLine(PointID p1, PointID p2, void *id = NULL);
int AddPolyClip(int *ps, int offset);
void AddPoly(int *points, int offset, void *id = NULL);
void AddPolyInv(int *points, int offset, void *id = NULL);
void ConvertLines(void);
int IsOutside(PointID p, PointID p1, PointID p2);
double TriangleCrossRate(PointID l1, PointID l2, PointID p1, PointID p2, PointID p3);
int TriangleIsFront(PointID p, PointID p1, PointID p2, PointID p3);
double CrossRate(PointID l1, PointID l2, PointID p1, PointID p2);
void ConvertLine(Poly *cpoly);
};
#endif