-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsg.h
More file actions
69 lines (55 loc) · 2.03 KB
/
csg.h
File metadata and controls
69 lines (55 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef RENDER_CSG_H
#define RENDER_CSG_H
#include "linkedlist.h"
#include "polygon.h"
typedef enum { CSG_Sets, CSG_Triangle, CSG_Plane, CSG_Cube, CSG_Cylinder, CSG_Triangular, CSG_Ball } CSGPrimitiveType;
typedef struct tagCSG {
CSGPrimitiveType type;
LinkedList *primitives;
} CSGSets;
typedef struct tagCSGPrimitive {
CSGPrimitiveType type;
} CSGPrimitive;
typedef struct tagCSGTriangle {
CSGPrimitiveType type;
Vector vertexes[3];
Vector surfaceNormal;
} CSGTriangle;
typedef struct tagCSGPlane {
CSGPrimitiveType type;
Vector vertexes[4];
Vector surfaceNormal;
} CSGPlane;
typedef struct tagCSGCube {
CSGPrimitiveType type;
Real size;
} CSGCube;
typedef struct tagCSGCylinder {
CSGPrimitiveType type;
Real radius;
Real height;
uint64_t partition;
} CSGCylinder, CSGTriangular;
typedef struct tagCSGBall {
CSGPrimitiveType type;
Real radius;
uint64_t partition;
} CSGBall;
CSGSets *CSGPrimitiveSetsCreate();
CSGPrimitive *CSGPrimitiveSetsAppend(CSGSets *sets, CSGPrimitive *primitive);
bool CSGPrimitiveSetsDestroy(CSGSets *sets);
CSGTriangle *CSGPrimitiveTriangleCreate(Vector vertexes[3], Vector surfaceNormal);
CSGPlane *CSGPrimitivePlaneCreate(Vector vertexes[4], Vector surfaceNormal);
CSGCube *CSGPrimitiveCubeCreate(Real size);
CSGCylinder *CSGPrimitiveCylinderCreate(Real radius, Real height, uint64_t partition);
CSGTriangular *CSGPrimitiveTriangularCreate(Real radius, Real height, uint64_t partition);
CSGBall *CSGPrimitiveBallCreate(Real radius, uint64_t partition);
void CSGPrimitivePlaneReduce(CSGSets *sets, const CSGPlane *plane);
void CSGPrimitiveCubeReduce(CSGSets *sets, const CSGCube *cube);
void CSGPrimitiveCylinderReduce(CSGSets *sets, const CSGCylinder *cylinder);
void CSGPrimitiveTriangularReduce(CSGSets *sets, const CSGCylinder *cylinder);
void CSGPrimitiveBallReduce(CSGSets *sets, const CSGBall *ball);
bool CSGPrimitiveReduce(CSGSets *sets, const CSGPrimitive *primitive);
void CSGPrimitiveSetsReduce(CSGSets *sets);
Polygon *CSGPrimitiveSetsPolygon(const CSGSets *sets);
#endif // RENDER_CSG_H