1 | //Copyright and Disclaimer: |
---|
2 | //This code is copyright Vienna University of Technology, 2004. |
---|
3 | |
---|
4 | #ifndef DATATYPES_H |
---|
5 | #define DATATYPES_H |
---|
6 | |
---|
7 | typedef double Vector3[3]; |
---|
8 | |
---|
9 | typedef Vector3 Vector3x8[8]; |
---|
10 | |
---|
11 | //Plane defined through normal vector n and distance to origin d |
---|
12 | struct Plane { |
---|
13 | Vector3 n; |
---|
14 | double d; |
---|
15 | }; |
---|
16 | |
---|
17 | //a dynamic array of planes |
---|
18 | struct VecPlane { |
---|
19 | struct Plane* plane; |
---|
20 | int size; |
---|
21 | }; |
---|
22 | |
---|
23 | //a dynamic array 3d points |
---|
24 | struct VecPoint { |
---|
25 | Vector3* points; |
---|
26 | int size; |
---|
27 | }; |
---|
28 | |
---|
29 | //a dynamic array of point list each point list is a polygon |
---|
30 | struct Object { |
---|
31 | struct VecPoint* poly; |
---|
32 | int size; |
---|
33 | }; |
---|
34 | |
---|
35 | //Axis-Aligned Bounding Box defined through the two extreme points |
---|
36 | struct AABox { |
---|
37 | Vector3 min; |
---|
38 | Vector3 max; |
---|
39 | }; |
---|
40 | |
---|
41 | //4x4 matrix |
---|
42 | typedef double Matrix4x4[16]; |
---|
43 | |
---|
44 | //initialisation objects (because we have no constructors) |
---|
45 | extern const struct Object OBJECT_NULL; |
---|
46 | extern const struct VecPoint VECPOINT_NULL; |
---|
47 | extern const struct VecPlane VECPLANE_NULL; |
---|
48 | |
---|
49 | //copy the 3 values of the input vector into the output vector |
---|
50 | extern void copyVector3(Vector3, const Vector3); |
---|
51 | //copy the 3 values of the input vector into the output vector |
---|
52 | extern void copyVector3Values(Vector3, const double, const double, const double); |
---|
53 | //copy the 3 values of the substraction of the two input vectors into the output vector |
---|
54 | extern void diffVector3(Vector3, const Vector3, const Vector3); |
---|
55 | //copy the 3 values of the addition of the two input vectors into the output vector |
---|
56 | extern void addVector3(Vector3 result, const Vector3, const Vector3); |
---|
57 | |
---|
58 | //copy the 16 values of the input matrix into the output matrix |
---|
59 | extern void copyMatrix(Matrix4x4, const Matrix4x4); |
---|
60 | |
---|
61 | extern void vecPointSetSize(struct VecPoint*, const int); |
---|
62 | extern void emptyVecPoint(struct VecPoint*); |
---|
63 | extern void swapVecPoint(struct VecPoint*, struct VecPoint*); |
---|
64 | extern void copyVecPoint(struct VecPoint*, const struct VecPoint); |
---|
65 | extern void append2VecPoint(struct VecPoint*, const Vector3); |
---|
66 | |
---|
67 | extern void emptyVecPlane(struct VecPlane*); |
---|
68 | |
---|
69 | extern void objectSetSize(struct Object*, const int); |
---|
70 | extern void emptyObject(struct Object*); |
---|
71 | extern void copyObject(struct Object*, const struct Object); |
---|
72 | //makes 1 VecPoint out of all the VecPoints of an object |
---|
73 | extern void convObject2VecPoint(struct VecPoint* points, const struct Object); |
---|
74 | |
---|
75 | //calculates the 8 corner points of the given AABox |
---|
76 | extern void calcAABoxPoints(Vector3x8 points, const struct AABox b); |
---|
77 | //calculates the 6 planes of the given AABox |
---|
78 | extern void calcAABoxPlanes(struct VecPlane*, const struct AABox); |
---|
79 | // allocates size planes and sets size variable |
---|
80 | extern void planesSetSize(struct VecPlane* p, const int size); |
---|
81 | // access plane per index |
---|
82 | extern double getPlaneCoeff(struct Plane* plane, int i); |
---|
83 | // set plane coefficienr per index |
---|
84 | extern void setPlaneCoeff(double coeff, struct Plane* plane, int i); |
---|
85 | |
---|
86 | #endif // DATATYPES |
---|