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

Comparing libgender/util.C (file contents):
Revision 1.41 by root, Thu Oct 28 23:24:49 2004 UTC vs.
Revision 1.42 by root, Fri Oct 29 22:32:49 2004 UTC

140 for (int i = 4; i--; ) 140 for (int i = 4; i--; )
141 for (int j = 4; j--; ) 141 for (int j = 4; j--; )
142 data[i][j] = i == j ? v : 0.; 142 data[i][j] = i == j ? v : 0.;
143 } 143 }
144 144
145 const matrix operator *(const matrix &a, const matrix &b) 145 matrix operator *(const matrix &a, const matrix &b)
146 { 146 {
147 matrix r; 147 matrix r;
148 148
149 // taken from mesa 149 // taken from mesa
150 for (int i = 0; i < 4; i++) 150 for (int i = 0; i < 4; i++)
158 } 158 }
159 159
160 return r; 160 return r;
161 } 161 }
162 162
163 const matrix matrix::rotation (GLfloat angle, const vec3 &axis) 163 matrix matrix::rotation (GLfloat angle, const vec3 &axis)
164 { 164 {
165 GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c; 165 GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c;
166 166
167 s = (GLfloat) sinf (angle * DEG2RAD); 167 s = (GLfloat) sinf (angle * DEG2RAD);
168 c = (GLfloat) cosf (angle * DEG2RAD); 168 c = (GLfloat) cosf (angle * DEG2RAD);
207 m(3,3) = 1; 207 m(3,3) = 1;
208 208
209 return m; 209 return m;
210 } 210 }
211 211
212 matrix matrix::translation (const vec3 &v)
213 {
214 matrix m(1);
215
216 m(0,3) = v.x;
217 m(1,3) = v.y;
218 m(2,3) = v.z;
219
220 return m;
221 }
222
223 matrix matrix::scaling (GLfloat sx, GLfloat sy, GLfloat sz, GLfloat sw)
224 {
225 matrix m (1.F);
226
227 m(0,0) = sx;
228 m(1,1) = sy;
229 m(2,2) = sz;
230 m(3,3) = sw;
231
232 return m;
233 }
234
212 const vec3 operator *(const matrix &a, const vec3 &v) 235 vec3 operator *(const matrix &a, const vec3 &v)
213 { 236 {
214 return vec3 ( 237 return vec3 (
215 a(0,0) * v.x + a(0,1) * v.y + a(0,2) * v.z + a(0,3), 238 a(0,0) * v.x + a(0,1) * v.y + a(0,2) * v.z + a(0,3),
216 a(1,0) * v.x + a(1,1) * v.y + a(1,2) * v.z + a(1,3), 239 a(1,0) * v.x + a(1,1) * v.y + a(1,2) * v.z + a(1,3),
217 a(2,0) * v.x + a(2,1) * v.y + a(2,2) * v.z + a(2,3) 240 a(2,0) * v.x + a(2,1) * v.y + a(2,2) * v.z + a(2,3)
225 printf ("[ %f, %f, %f, %f ]\n", data[0][1], data[1][1], data[2][1], data[3][1]); 248 printf ("[ %f, %f, %f, %f ]\n", data[0][1], data[1][1], data[2][1], data[3][1]);
226 printf ("[ %f, %f, %f, %f ]\n", data[0][2], data[1][2], data[2][2], data[3][2]); 249 printf ("[ %f, %f, %f, %f ]\n", data[0][2], data[1][2], data[2][2], data[3][2]);
227 printf ("[ %f, %f, %f, %f ]\n", data[0][3], data[1][3], data[2][3], data[3][3]); 250 printf ("[ %f, %f, %f, %f ]\n", data[0][3], data[1][3], data[2][3], data[3][3]);
228 } 251 }
229 252
230 const matrix matrix::translation (const vec3 &v)
231 {
232 matrix m(1);
233
234 m(0,3) = v.x;
235 m(1,3) = v.y;
236 m(2,3) = v.z;
237
238 return m;
239 }
240
241 ///////////////////////////////////////////////////////////////////////////// 253 /////////////////////////////////////////////////////////////////////////////
242 254
243 void draw_bbox (const sector &a, const sector &b) 255 void draw_bbox (const sector &a, const sector &b)
244 { 256 {
245 static vertex_buffer_object vb; 257 static vertex_buffer vb;
246 static index_buffer_object ib; 258 static index_buffer ib;
247 259
248 point pa(a), pb(b); 260 point pa(a), pb(b);
249 261
250 vertex_v3f vd[] = { 262 vertex_v3f vd[] = {
251 point (a.x, a.y, a.z), 263 point (a.x, a.y, a.z),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines