source: GTP/trunk/App/Demos/Vis/Teapots/DataTypes.h @ 643

Revision 643, 2.7 KB checked in by mattausch, 18 years ago (diff)

made demo running

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