ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.h
(Generate patch)

Comparing libgender/util.h (file contents):
Revision 1.9 by root, Mon Oct 4 07:04:58 2004 UTC vs.
Revision 1.10 by root, Mon Oct 4 10:18:13 2004 UTC

15#define SOFFS_MAX (soffs)+(1 << (OFFS_BITS - 2)) 15#define SOFFS_MAX (soffs)+(1 << (OFFS_BITS - 2))
16#define MAXEXTENT (1UL << (OFFS_BITS - 1)) 16#define MAXEXTENT (1UL << (OFFS_BITS - 1))
17 17
18#define GLFLOAT_MAX 1e30 18#define GLFLOAT_MAX 1e30
19#define GLFLOAT_MIN -1e30 19#define GLFLOAT_MIN -1e30
20
21struct sector {
22 soffs x, y, z;
23
24 sector (soffs x = 0, soffs y = 0, soffs z = 0) : x(x), y(y), z(z) { };
25
26 void offset (int subindex, uoffs extent)
27 {
28 if (subindex & 1) x += extent;
29 if (subindex & 2) y += extent;
30 if (subindex & 4) z += extent;
31 }
32};
33
34struct point {
35 GLfloat x, y, z;
36
37 point () { };
38 point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
39};
40
41inline const sector translate (const sector &p, const sector &src, const sector &dst)
42{
43 sector r;
44
45 r.x = p.x + (dst.x - src.x);
46 r.y = p.y + (dst.y - src.y);
47 r.z = p.z + (dst.z - src.z);
48
49 return r;
50}
51
52void renormalize (sector &s, point &p);
53
54struct colour {
55 GLfloat r, g, b, a;
56 colour (GLfloat r = 1., GLfloat g = 1., GLfloat b = 1., GLfloat a = 1.) : r(r), g(g), b(b), a(a) { };
57};
58 20
59struct vec3 { 21struct vec3 {
60 GLfloat x, y, z; 22 GLfloat x, y, z;
61 vec3 () { }; 23 vec3 () { };
62 vec3 (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { }; 24 vec3 (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
102 gl_matrix (GLfloat diag) { diagonal (diag); }; 64 gl_matrix (GLfloat diag) { diagonal (diag); };
103}; 65};
104 66
105const gl_matrix operator *(const gl_matrix &a, const gl_matrix &b); 67const gl_matrix operator *(const gl_matrix &a, const gl_matrix &b);
106const vec3 operator *(const gl_matrix &a, const vec3 &v); 68const vec3 operator *(const gl_matrix &a, const vec3 &v);
69
70typedef vec3 point;
71
72// a generic plane
73class plane {
74 vec3 n;
75 GLfloat d;
76public:
77
78 GLfloat distance (const point &p) const
79 {
80 return dot (n, p) + d;
81 }
82
83 plane () { };
84 plane (GLfloat a, GLfloat b, GLfloat c, GLfloat d);
85};
86
87struct sector {
88 soffs x, y, z;
89
90 sector (soffs x = 0, soffs y = 0, soffs z = 0) : x(x), y(y), z(z) { };
91
92 void offset (int subindex, uoffs extent)
93 {
94 if (subindex & 1) x += extent;
95 if (subindex & 2) y += extent;
96 if (subindex & 4) z += extent;
97 }
98};
99
100inline const sector translate (const sector &p, const sector &src, const sector &dst)
101{
102 sector r;
103
104 r.x = p.x + (dst.x - src.x);
105 r.y = p.y + (dst.y - src.y);
106 r.z = p.z + (dst.z - src.z);
107
108 return r;
109}
110
111void renormalize (sector &s, point &p);
112
113struct colour {
114 GLfloat r, g, b, a;
115 colour (GLfloat r = 1., GLfloat g = 1., GLfloat b = 1., GLfloat a = 1.) : r(r), g(g), b(b), a(a) { };
116};
107 117
108struct texc { 118struct texc {
109 GLfloat s, t; 119 GLfloat s, t;
110 texc () { }; 120 texc () { };
111 texc (GLfloat s, GLfloat t) : s(s), t(t) { }; 121 texc (GLfloat s, GLfloat t) : s(s), t(t) { };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines