Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gl_matrix.cpp File Reference
#include "gl_globals.h"
#include "gfxlib.h"
#include "gfx/vec.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include "gfx/matrix.h"
#include "vs_globals.h"
#include "gl_matrix.h"

Go to the source code of this file.

Macros

#define M(row, col)   m[col*4+row]
 
#define M(row, col)   i[col*4+row]
 
#define M(row, col)   m[col*4+row]
 
#define M(row, col)   view.r[col*3+row]
 

Functions

void getInverseProjection (float *&inv)
 
float GFXGetXInvPerspective ()
 Screen to eye. More...
 
float GFXGetYInvPerspective ()
 
void MatrixToDoubles (double t[], const Matrix &m)
 
void ViewToModel ()
 
static void IdentityFloat (float id[])
 
void MultFloatMatrix (float dest[], const float m1[], const Matrix &m2)
 
static void RotateFloatMatrix (float dest[], const float m1[], const Matrix &m2)
 
void ConstructAndLoadProjection ()
 
void GFXTranslateView (const QVector &a)
 
void GFXTranslateModel (const QVector &a)
 
void GFXTranslateProjection (const Vector &a)
 Translates the current "mode" matrix by a given vector. More...
 
void GFXMultMatrixModel (const Matrix &matrix)
 Multipliex the current "mode" matrix by a given matrix. More...
 
void GFXLoadMatrixView (const Matrix &matrix)
 
void GFXLoadMatrixModel (const Matrix &matrix)
 loads a given matrix to the current "mode" More...
 
void GFXLoadMatrixProjection (const float matrix[16])
 
void GFXViewPort (int minx, int miny, int maxx, int maxy)
 Sets the final translation to screen coordinates, Also adjusts range of clearing. More...
 
void GFXCenterCamera (bool Enter)
 
void GFXRestoreHudMode ()
 
void GFXHudMode (const bool Enter)
 
void GFXLoadIdentity (const MATRIXMODE mode)
 Loads the identity matrix for the given mode. More...
 
void GFXGetMatrixView (Matrix &matrix)
 
void GFXGetMatrixModel (Matrix &matrix)
 retrieves the matrix for a given mode. More...
 
static void gl_Frustum (float left, float right, float bottom, float top, float nearval, float farval)
 
void GFXFrustum (float *m, float *i, float left, float right, float bottom, float top, float nearval, float farval)
 Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates. More...
 
void GFXPerspective (float fov, float aspect, float znear, float zfar, float cockpit_offset)
 Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes. More...
 
void GFXParallel (float left, float right, float bottom, float top, float nearval, float farval)
 Sets the Projection matrix to a parallel view with given paramters. More...
 
static void LookAtHelper (float eyex, float eyey, float eyez, double centerx, double centery, double centerz, float upx, float upy, float upz)
 
void GFXLookAt (Vector eye, QVector center, Vector up)
 Sets the VIEW matrix to look from center in direction of eye with up vector up. More...
 

Macro Definition Documentation

#define M (   row,
  col 
)    m[col*4+row]
#define M (   row,
  col 
)    i[col*4+row]
#define M (   row,
  col 
)    m[col*4+row]
#define M (   row,
  col 
)    view.r[col*3+row]

Function Documentation

void ConstructAndLoadProjection ( )

Definition at line 157 of file gl_matrix.cpp.

References GFXMatrices::projection, RotateFloatMatrix(), and GFXMatrices::view.

Referenced by GFXLoadIdentity(), GFXLoadMatrixProjection(), GFXLoadMatrixView(), GFXPerspective(), and GFXTranslateProjection().

158 {
159  float t[16];
161  glMatrixMode( GL_PROJECTION );
162  glLoadMatrixf( t );
163 }
void getInverseProjection ( float *&  inv)

Definition at line 46 of file gl_matrix.cpp.

References GFXMatrices::invprojection.

47 {
48  inv = invprojection;
49 }
void GFXCenterCamera ( bool  Enter)

Definition at line 224 of file gl_matrix.cpp.

References GFXLoadIdentity(), MODEL, Matrix::p, QVector, and GFXMatrices::view.

Referenced by Background::Draw(), and Mesh::DrawNow().

225 {
226  static QVector tmp;
227  if (Enter) {
228  tmp = view.p;
229  view.p.Set( 0, 0, 0 );
230  glMatrixMode( GL_MODELVIEW );
231  glLoadIdentity();
232  } else {
233  view.p = tmp;
235  }
236 }
void GFXFrustum ( float m,
float i,
float  left,
float  right,
float  bottom,
float  top,
float  nearval,
float  farval 
)

Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates.

Definition at line 303 of file gl_matrix.cpp.

References a, b, c, d, float, M, x, and y.

304 {
305  GLfloat x, y, a, b, c, d;
306  x = ( ( (float) 2.0 )*nearval )/(right-left);
307  y = ( ( (float) 2.0 )*nearval )/(top-bottom);
308  a = (right+left)/(right-left);
309  b = (top+bottom)/(top-bottom);
310  //If farval == 0, we'll build an infinite-farplane projection matrix.
311  if (farval == 0) {
312  c = -1.0;
313  d = -1.99*nearval; //-2*nearval, but using exactly -2 might create artifacts
314  } else {
315  c = -(farval+nearval)/(farval-nearval);
316  d = -( ( (float) 2.0 )*farval*nearval )/(farval-nearval);
317  }
318 #define M( row, col ) m[col*4+row]
319  M( 0, 0 ) = x;
320  M( 0, 1 ) = 0.0F;
321  M( 0, 2 ) = a;
322  M( 0, 3 ) = 0.0F;
323  M( 1, 0 ) = 0.0F;
324  M( 1, 1 ) = y;
325  M( 1, 2 ) = b;
326  M( 1, 3 ) = 0.0F;
327  M( 2, 0 ) = 0.0F;
328  M( 2, 1 ) = 0.0F;
329  M( 2, 2 ) = c;
330  M( 2, 3 ) = d;
331  M( 3, 0 ) = 0.0F;
332  M( 3, 1 ) = 0.0F;
333  M( 3, 2 ) = -1.0F;
334  M( 3, 3 ) = 0.0F;
335 #undef M
336 #define M( row, col ) i[col*4+row]
337  M( 0, 0 ) = 1./x;
338  M( 0, 1 ) = 0.0F;
339  M( 0, 2 ) = 0.0F;
340  M( 0, 3 ) = a/x;
341  M( 1, 0 ) = 0.0F;
342  M( 1, 1 ) = 1./y;
343  M( 1, 2 ) = 0.0F;
344  M( 1, 3 ) = b/y;
345  M( 2, 0 ) = 0.0F;
346  M( 2, 1 ) = 0.0F;
347  M( 2, 2 ) = 0.0F;
348  M( 2, 3 ) = -1.0F;
349  M( 3, 0 ) = 0.0F;
350  M( 3, 1 ) = 0.0F;
351  M( 3, 2 ) = 1.F/d;
352  M( 3, 3 ) = (float) c/d;
353 #undef M
354 }
void GFXGetMatrixModel ( Matrix matrix)

retrieves the matrix for a given mode.

Definition at line 292 of file gl_matrix.cpp.

References CopyMatrix(), and GFXMatrices::model.

Referenced by LocationSelect::Draw(), and GFXUploadLightState().

293 {
294  CopyMatrix( matrix, model );
295 }
void GFXGetMatrixView ( Matrix matrix)

Definition at line 288 of file gl_matrix.cpp.

References CopyMatrix(), and GFXMatrices::view.

Referenced by LocationSelect::Draw(), and Camera::GetView().

289 {
290  CopyMatrix( matrix, view );
291 }
float GFXGetXInvPerspective ( )

Screen to eye.

Definition at line 51 of file gl_matrix.cpp.

References GFXMatrices::invprojection.

52 {
53  return /*invprojection[11]* */ invprojection[0]; //invprojection[15];//should be?? c/d == invproj[15]
54 }
float GFXGetYInvPerspective ( )

Definition at line 56 of file gl_matrix.cpp.

References GFXMatrices::invprojection.

57 {
58  return /*invprojection[11]* */ invprojection[5]; //invprojection[15];//should be?? c/d == invproj[15]
59 }
void GFXHudMode ( const bool  Enter)

Hud Mode saves the current matrices and sets projection and view matrices to identity. Caution: use of other matrix functions in HudMode could alter state.

Definition at line 246 of file gl_matrix.cpp.

247 {
248  if (Enter) {
249  glMatrixMode( GL_MODELVIEW );
250  glPushMatrix();
251  glLoadIdentity();
252  glMatrixMode( GL_PROJECTION );
253  glPushMatrix();
254  glLoadIdentity();
255  } else {
256  glMatrixMode( GL_PROJECTION );
257  glPopMatrix();
258  glMatrixMode( GL_MODELVIEW );
259  glPopMatrix();
260  }
261 }
void GFXLoadIdentity ( const MATRIXMODE  mode)

Loads the identity matrix for the given mode.

Definition at line 263 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), GFX_SCALE, Identity(), IdentityFloat(), GFXMatrices::model, MODEL, Matrix::p, GFXMatrices::projection, PROJECTION, GFXMatrices::view, VIEW, and ViewToModel().

264 {
265  switch (mode)
266  {
267  case MODEL:
268  Identity( model );
269  glMatrixMode( GL_MODELVIEW );
270  //glLoadMatrixf(transview);
271  glLoadIdentity();
272  glTranslated( -view.p.i*GFX_SCALE, -view.p.j*GFX_SCALE, -view.p.k*GFX_SCALE );
273  glScalef( GFX_SCALE, GFX_SCALE, GFX_SCALE );
274  break;
275  case PROJECTION:
278  break;
279  case VIEW:
280  Identity( view );
281  ViewToModel();
282  glMatrixMode( GL_PROJECTION );
283  glLoadMatrixf( projection );
284  break;
285  }
286 }
void GFXLoadMatrixModel ( const Matrix matrix)
void GFXLoadMatrixProjection ( const float  matrix[16])

Definition at line 213 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), VsnetOSS::memcpy(), and GFXMatrices::projection.

Referenced by GFXParallel().

214 {
215  memcpy( projection, matrix, 16*sizeof (float) );
217 }
void GFXLoadMatrixView ( const Matrix matrix)

Definition at line 200 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), CopyMatrix(), GFXMatrices::view, and ViewToModel().

Referenced by GFXLookAt().

201 {
202  CopyMatrix( view, matrix );
203  ViewToModel();
205 }
void GFXLookAt ( Vector  eye,
QVector  center,
Vector  up 
)

Sets the VIEW matrix to look from center in direction of eye with up vector up.

Definition at line 495 of file gl_matrix.cpp.

References GFXLoadMatrixView(), LookAtHelper(), and GFXMatrices::view.

Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().

496 {
497  LookAtHelper( eye.i, eye.j, eye.k, center.i, center.j, center.k, up.i, up.j, up.k );
499 }
void GFXMultMatrixModel ( const Matrix matrix)

Multipliex the current "mode" matrix by a given matrix.

Definition at line 189 of file gl_matrix.cpp.

References CopyMatrix(), GFXMatrices::model, MultMatrix(), and ViewToModel().

Referenced by LocationSelect::Draw().

190 {
191  Matrix t;
192  MultMatrix( t, model, matrix );
193  CopyMatrix( model, t );
194  ViewToModel();
195 }
void GFXParallel ( float  left,
float  right,
float  bottom,
float  top,
float  nearval,
float  farval 
)

Sets the Projection matrix to a parallel view with given paramters.

Definition at line 376 of file gl_matrix.cpp.

References GFXGetFrustumVars(), GFXLoadMatrixProjection(), M, GFXMatrices::projection, x, y, and z.

377 {
378  float *m = projection, x, y, z, tx, ty, tz;
379  x = 2.0/(right-left);
380  y = 2.0/(top-bottom);
381  z = -2.0/(farval-nearval);
382  tx = -(right+left)/(right-left);
383  ty = -(top+bottom)/(top-bottom);
384  tz = -(farval+nearval)/(farval-nearval);
385 
386 #define M( row, col ) m[col*4+row]
387  M( 0, 0 ) = x;
388  M( 0, 1 ) = 0.0F;
389  M( 0, 2 ) = 0.0F;
390  M( 0, 3 ) = tx;
391  M( 1, 0 ) = 0.0F;
392  M( 1, 1 ) = y;
393  M( 1, 2 ) = 0.0F;
394  M( 1, 3 ) = ty;
395  M( 2, 0 ) = 0.0F;
396  M( 2, 1 ) = 0.0F;
397  M( 2, 2 ) = z;
398  M( 2, 3 ) = tz;
399  M( 3, 0 ) = 0.0F;
400  M( 3, 1 ) = 0.0F;
401  M( 3, 2 ) = 0.0F;
402  M( 3, 3 ) = 1.0F;
403 #undef M
405  GFXGetFrustumVars( false, &left, &right, &bottom, &top, &nearval, &farval );
406 }
void GFXPerspective ( float  fov,
float  aspect,
float  znear,
float  zfar,
float  cockpit_offset 
)

Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes.

Definition at line 356 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), GFX_SCALE, gl_Frustum(), and M_PI.

357 {
358  znear *= GFX_SCALE;
359  zfar *= GFX_SCALE;
360  cockpit_offset *= GFX_SCALE;
361  //gluPerspective (fov,aspect,znear,zfar);
362 
363  float xmin, xmax, ymin, ymax;
364 
365  ymax = znear*tanf( fov*M_PI/( (float) 360.0 ) ); //78.0 --> 4.7046
366 
367  ymin = -ymax; //-4.7046
368 
369  xmin = (ymin-cockpit_offset/2)*aspect; //-6.2571
370  xmax = (ymax+cockpit_offset/2)*aspect; //6.2571
371  ymin -= cockpit_offset;
372  gl_Frustum( xmin, xmax, ymin, ymax, znear, zfar );
374 }
void GFXRestoreHudMode ( )

Definition at line 238 of file gl_matrix.cpp.

239 {
240  glMatrixMode( GL_MODELVIEW );
241  glLoadIdentity();
242  glMatrixMode( GL_PROJECTION );
243  glLoadIdentity();
244 }
void GFXTranslateModel ( const QVector a)

Definition at line 175 of file gl_matrix.cpp.

References GFXMatrices::model, Matrix::p, TransformNormal(), and ViewToModel().

Referenced by Stars::Draw(), and ParticleTrail::DrawAndUpdate().

176 {
177  model.p += TransformNormal( model, a );
178  ViewToModel();
179 }
void GFXTranslateProjection ( const Vector a)

Translates the current "mode" matrix by a given vector.

Definition at line 181 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), and GFXMatrices::projection.

182 {
183  projection[12] += a.i*projection[0]+a.j*projection[4]+a.k*projection[8];
184  projection[13] += a.i*projection[1]+a.j*projection[5]+a.k*projection[9];
185  projection[14] += a.i*projection[2]+a.j*projection[6]+a.k*projection[10];
187 }
void GFXTranslateView ( const QVector a)

Definition at line 165 of file gl_matrix.cpp.

References Matrix::p, TransformNormal(), GFXMatrices::view, and ViewToModel().

166 {
167  view.p += TransformNormal( view, a );
168  //glPopMatrix();
169  //glLoadIdentity();
170  //glTranslatef(-view[12],-view[13],-view[14]);
171  //glPushMatrix();
172  ViewToModel();
173 }
void GFXViewPort ( int  minx,
int  miny,
int  maxx,
int  maxy 
)

Sets the final translation to screen coordinates, Also adjusts range of clearing.

Definition at line 219 of file gl_matrix.cpp.

220 {
221  glViewport( minx, miny, maxx, maxy );
222 }
static void gl_Frustum ( float  left,
float  right,
float  bottom,
float  top,
float  nearval,
float  farval 
)
static

Definition at line 297 of file gl_matrix.cpp.

References GFXFrustum(), GFXGetFrustumVars(), GFXMatrices::invprojection, and GFXMatrices::projection.

Referenced by GFXPerspective().

298 {
299  GFXGetFrustumVars( false, &left, &right, &bottom, &top, &nearval, &farval );
300  GFXFrustum( projection, invprojection, left, right, bottom, top, nearval, farval );
301 }
static void IdentityFloat ( float  id[])
static

Definition at line 105 of file gl_matrix.cpp.

Referenced by GFXLoadIdentity().

106 {
107  id[0] = id[5] = id[10] = id[15] = 1;
108  id[1] = id[2] = id[3] = id[4] = id[6] = id[7] = id[8] = id[9] = id[11] = id[12] = id[13] = id[14] = 0;
109 }
static void LookAtHelper ( float  eyex,
float  eyey,
float  eyez,
double  centerx,
double  centery,
double  centerz,
float  upx,
float  upy,
float  upz 
)
static

Definition at line 408 of file gl_matrix.cpp.

References M, Matrix::p, GFXMatrices::view, x, y, and z.

Referenced by GFXLookAt().

417 {
418  //Matrix m;
419  double x[3], y[3], z[3];
420  double mag;
421 
422  /* Make rotation matrix */
423 
424  /* Z vector */
425  z[0] = eyex;
426  z[1] = eyey;
427  z[2] = eyez;
428  mag = sqrtf( z[0]*z[0]+z[1]*z[1]+z[2]*z[2] );
429  if (mag) {
430  /* mpichler, 19950515 */
431  z[0] /= mag;
432  z[1] /= mag;
433  z[2] /= mag;
434  }
435  /* Y vector */
436  y[0] = upx;
437  y[1] = upy;
438  y[2] = upz;
439 
440  /* X vector = Y cross Z */
441  //x[0] = z[1]*y[2] - z[2]*y[1];
442  //x[1] = -z[0]*y[2] + z[2]*y[0];
443  //x[2] = z[0]*y[1] - z[1]*y[0];
444  x[0] = y[1]*z[2]-y[2]*z[1];
445  x[1] = -y[0]*z[2]+y[2]*z[0];
446  x[2] = y[0]*z[1]-y[1]*z[0];
447 
448  /* Recompute Y = Z cross X */
449  //y[0] = x[1]*z[2] - x[2]*z[1];
450  //y[1] = -x[0]*z[2] + x[2]*z[0];
451  //y[2] = x[0]*z[1] - x[1]*z[0];
452  y[0] = z[1]*x[2]-z[2]*x[1];
453  y[1] = -z[0]*x[2]+z[2]*x[0];
454  y[2] = z[0]*x[1]-z[1]*x[0];
455 
456  /* mpichler, 19950515 */
457  /* cross product gives area of parallelogram, which is < 1.0 for
458  * non-perpendicular unit-length vectors; so normalize x, y here
459  */
460 
461  mag = sqrtf( x[0]*x[0]+x[1]*x[1]+x[2]*x[2] );
462  if (mag) {
463  x[0] /= mag;
464  x[1] /= mag;
465  x[2] /= mag;
466  }
467  mag = sqrtf( y[0]*y[0]+y[1]*y[1]+y[2]*y[2] );
468  if (mag) {
469  y[0] /= mag;
470  y[1] /= mag;
471  y[2] /= mag;
472  }
473 #define M( row, col ) view.r[col*3+row]
474  M( 0, 0 ) = x[0];
475  M( 0, 1 ) = x[1];
476  M( 0, 2 ) = x[2]; //M(0,3) = 0.0;
477  M( 1, 0 ) = y[0];
478  M( 1, 1 ) = y[1];
479  M( 1, 2 ) = y[2]; //M(1,3) = 0.0;
480  M( 2, 0 ) = z[0];
481  M( 2, 1 ) = z[1];
482  M( 2, 2 ) = z[2]; //M(2,3) = 0.0;
483 #undef M
484  //M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0;
485 
486  //Matrix tm;
487  //Identity(tm);
488  view.p.i = centerx+eyex;
489  view.p.j = centery+eyey;
490  view.p.k = centerz+eyez;
491  //CopyMatrix (view,m);
492  //MultMatrix(view, m, tm);
493 }
void MatrixToDoubles ( double  t[],
const Matrix m 
)

Definition at line 61 of file gl_matrix.cpp.

References Matrix::p, and Matrix::r.

62 {
63  t[0] = m.r[0]; //possible performance hit?!?!
64  t[1] = m.r[1];
65  t[2] = m.r[2];
66  t[3] = 0;
67  t[4] = m.r[3];
68  t[5] = m.r[4];
69  t[6] = m.r[5];
70  t[7] = 0;
71  t[8] = m.r[6];
72  t[9] = m.r[7];
73  t[10] = m.r[8];
74  t[11] = 0;
75  t[12] = (m.p.i);
76  t[13] = (m.p.j);
77  t[14] = (m.p.k);
78  t[15] = 1;
79 }
void MultFloatMatrix ( float  dest[],
const float  m1[],
const Matrix m2 
)

Definition at line 111 of file gl_matrix.cpp.

References Matrix::p, and Matrix::r.

112 {
113  dest[0] = m1[0]*m2.r[0]+m1[4]*m2.r[1]+m1[8]*m2.r[2];
114  dest[1] = m1[1]*m2.r[0]+m1[5]*m2.r[1]+m1[9]*m2.r[2];
115  dest[2] = m1[2]*m2.r[0]+m1[6]*m2.r[1]+m1[10]*m2.r[2];
116  dest[3] = m1[3]*m2.r[0]+m1[7]*m2.r[1]+m1[11]*m2.r[2];
117 
118  dest[4] = m1[0]*m2.r[3]+m1[4]*m2.r[4]+m1[8]*m2.r[5];
119  dest[5] = m1[1]*m2.r[3]+m1[5]*m2.r[4]+m1[9]*m2.r[5];
120  dest[6] = m1[2]*m2.r[3]+m1[6]*m2.r[4]+m1[10]*m2.r[5];
121  dest[7] = m1[3]*m2.r[3]+m1[7]*m2.r[4]+m1[11]*m2.r[5];
122 
123  dest[8] = m1[0]*m2.r[6]+m1[4]*m2.r[7]+m1[8]*m2.r[8];
124  dest[9] = m1[1]*m2.r[6]+m1[5]*m2.r[7]+m1[9]*m2.r[8];
125  dest[10] = m1[2]*m2.r[6]+m1[6]*m2.r[7]+m1[10]*m2.r[8];
126  dest[11] = m1[3]*m2.r[6]+m1[7]*m2.r[7]+m1[11]*m2.r[8];
127 
128  dest[12] = m1[0]*m2.p.i+m1[4]*m2.p.j+m1[8]*m2.p.k+m1[12];
129  dest[13] = m1[1]*m2.p.i+m1[5]*m2.p.j+m1[9]*m2.p.k+m1[13];
130  dest[14] = m1[2]*m2.p.i+m1[6]*m2.p.j+m1[10]*m2.p.k+m1[14];
131  dest[15] = m1[3]*m2.p.i+m1[7]*m2.p.j+m1[11]*m2.p.k+m1[15];
132 }
static void RotateFloatMatrix ( float  dest[],
const float  m1[],
const Matrix m2 
)
static

Definition at line 134 of file gl_matrix.cpp.

References Matrix::r.

Referenced by ConstructAndLoadProjection().

135 {
136  dest[0] = (m1[0]*m2.r[0]+m1[4]*m2.r[1]+m1[8]*m2.r[2]);
137  dest[1] = (m1[1]*m2.r[0]+m1[5]*m2.r[1]+m1[9]*m2.r[2]);
138  dest[2] = (m1[2]*m2.r[0]+m1[6]*m2.r[1]+m1[10]*m2.r[2]);
139  dest[3] = (m1[3]*m2.r[0]+m1[7]*m2.r[1]+m1[11]*m2.r[2]);
140 
141  dest[4] = (m1[0]*m2.r[3]+m1[4]*m2.r[4]+m1[8]*m2.r[5]);
142  dest[5] = (m1[1]*m2.r[3]+m1[5]*m2.r[4]+m1[9]*m2.r[5]);
143  dest[6] = (m1[2]*m2.r[3]+m1[6]*m2.r[4]+m1[10]*m2.r[5]);
144  dest[7] = (m1[3]*m2.r[3]+m1[7]*m2.r[4]+m1[11]*m2.r[5]);
145 
146  dest[8] = (m1[0]*m2.r[6]+m1[4]*m2.r[7]+m1[8]*m2.r[8]);
147  dest[9] = (m1[1]*m2.r[6]+m1[5]*m2.r[7]+m1[9]*m2.r[8]);
148  dest[10] = (m1[2]*m2.r[6]+m1[6]*m2.r[7]+m1[10]*m2.r[8]);
149  dest[11] = (m1[3]*m2.r[6]+m1[7]*m2.r[7]+m1[11]*m2.r[8]);
150 
151  dest[12] = m1[12];
152  dest[13] = m1[13];
153  dest[14] = m1[14];
154  dest[15] = m1[15];
155 }
void ViewToModel ( )
inline

Definition at line 81 of file gl_matrix.cpp.

References GFX_SCALE, GFXMatrices::model, Matrix::p, Matrix::r, and GFXMatrices::view.

Referenced by GFXLoadIdentity(), GFXLoadMatrixModel(), GFXLoadMatrixView(), GFXMultMatrixModel(), GFXTranslateModel(), and GFXTranslateView().

82 {
83  double t[16];
84  t[0] = model.r[0]*GFX_SCALE; //possible performance hit?!?!
85  t[1] = model.r[1]*GFX_SCALE;
86  t[2] = model.r[2]*GFX_SCALE;
87  t[3] = 0;
88  t[4] = model.r[3]*GFX_SCALE;
89  t[5] = model.r[4]*GFX_SCALE;
90  t[6] = model.r[5]*GFX_SCALE;
91  t[7] = 0;
92  t[8] = model.r[6]*GFX_SCALE;
93  t[9] = model.r[7]*GFX_SCALE;
94  t[10] = model.r[8]*GFX_SCALE;
95  t[11] = 0;
96  t[12] = (model.p.i-view.p.i)*GFX_SCALE;
97  t[13] = (model.p.j-view.p.j)*GFX_SCALE;
98  t[14] = (model.p.k-view.p.k)*GFX_SCALE;
99  t[15] = 1;
100  //MatrixToDoubles (t,model);
101  glMatrixMode( GL_MODELVIEW );
102  glLoadMatrixd( t );
103 }