OpenClonk
StdProjectionMatrix Class Reference

#include <StdMeshMath.h>

Public Member Functions

float & operator() (int i, int j)
 
float operator() (int i, int j) const
 
const float * data () const
 

Static Public Member Functions

static StdProjectionMatrix Identity ()
 
static StdProjectionMatrix Translate (float dx, float dy, float dz)
 
static StdProjectionMatrix Scale (float sx, float sy, float sz)
 
static StdProjectionMatrix Rotate (float angle, float rx, float ry, float rz)
 
static StdProjectionMatrix Orthographic (float left, float right, float bottom, float top)
 
static StdMeshMatrix Upper3x4 (const StdProjectionMatrix &matrix)
 

Static Public Attributes

static const int NColumns = 4
 
static const int NRows = 4
 

Detailed Description

Definition at line 119 of file StdMeshMath.h.

Member Function Documentation

◆ data()

const float* StdProjectionMatrix::data ( ) const
inline

Definition at line 137 of file StdMeshMath.h.

137 { return &a[0][0]; }

Referenced by C4ShaderCall::SetUniformMatrix4x4().

Here is the caller graph for this function:

◆ Identity()

StdProjectionMatrix StdProjectionMatrix::Identity ( )
static

Definition at line 364 of file StdMeshMath.cpp.

365 {
367  m.a[0][0] = 1.0f; m.a[0][1] = 0.0f; m.a[0][2] = 0.0f; m.a[0][3] = 0.0f;
368  m.a[1][0] = 0.0f; m.a[1][1] = 1.0f; m.a[1][2] = 0.0f; m.a[1][3] = 0.0f;
369  m.a[2][0] = 0.0f; m.a[2][1] = 0.0f; m.a[2][2] = 1.0f; m.a[2][3] = 0.0f;
370  m.a[3][0] = 0.0f; m.a[3][1] = 0.0f; m.a[3][2] = 0.0f; m.a[3][3] = 1.0f;
371  return m;
372 }

Referenced by C4ParticleList::Draw(), CStdGL::PerformMesh(), and CStdGL::SetupMultiBlt().

Here is the caller graph for this function:

◆ operator()() [1/2]

float& StdProjectionMatrix::operator() ( int  i,
int  j 
)
inline

Definition at line 134 of file StdMeshMath.h.

134 { return a[i][j]; }

◆ operator()() [2/2]

float StdProjectionMatrix::operator() ( int  i,
int  j 
) const
inline

Definition at line 135 of file StdMeshMath.h.

135 { return a[i][j]; }

◆ Orthographic()

StdProjectionMatrix StdProjectionMatrix::Orthographic ( float  left,
float  right,
float  bottom,
float  top 
)
static

Definition at line 411 of file StdMeshMath.cpp.

412 {
413  StdProjectionMatrix matrix;
414  matrix(0,0) = 2.0f / (right - left);
415  matrix(0,1) = 0.0f;
416  matrix(0,2) = 0.0f;
417  matrix(0,3) = -(right + left) / (right - left);
418  matrix(1,0) = 0.0f;
419  matrix(1,1) = 2.0f / (top - bottom);
420  matrix(1,2) = 0.0f;
421  matrix(1,3) = -(top + bottom) / (top - bottom);
422  matrix(2,0) = 0.0f;
423  matrix(2,1) = 0.0f;
424  matrix(2,2) = -1.0f;
425  matrix(2,3) = 0.0f;
426  matrix(3,0) = 0.0f;
427  matrix(3,1) = 0.0f;
428  matrix(3,2) = 0.0f;
429  matrix(3,3) = 1.0f;
430  return matrix;
431 }

References C4ScriptGuiWindowPropertyName::bottom, C4ScriptGuiWindowPropertyName::left, C4ScriptGuiWindowPropertyName::right, and C4ScriptGuiWindowPropertyName::top.

Referenced by C4FoWRegion::Render(), and CStdGL::UpdateClipper().

Here is the caller graph for this function:

◆ Rotate()

StdProjectionMatrix StdProjectionMatrix::Rotate ( float  angle,
float  rx,
float  ry,
float  rz 
)
static

Definition at line 394 of file StdMeshMath.cpp.

395 {
397 
398  // We do normalize the rx,ry,rz vector here: This is only required for
399  // precalculations anyway, thus not time-critical.
400  float abs = sqrt(rx*rx+ry*ry+rz*rz);
401  rx/=abs; ry/=abs; rz/=abs;
402  float c = cos(angle), s = sin(angle);
403 
404  m.a[0][0] = rx*rx*(1-c)+c; m.a[0][1] = rx*ry*(1-c)-rz*s; m.a[0][2] = rx*rz*(1-c)+ry*s; m.a[0][3] = 0.0f;
405  m.a[1][0] = ry*rx*(1-c)+rz*s; m.a[1][1] = ry*ry*(1-c)+c; m.a[1][2] = ry*rz*(1-c)-rx*s; m.a[1][3] = 0.0f;
406  m.a[2][0] = rz*rx*(1-c)-ry*s; m.a[2][1] = ry*rz*(1-c)+rx*s; m.a[2][2] = rz*rz*(1-c)+c; m.a[2][3] = 0.0f;
407  m.a[3][0] = 0.0f; m.a[3][1] = 0.0f; m.a[3][2] = 0.0f; m.a[3][3] = 1.0f;
408  return m;
409 }
#define s

References s.

◆ Scale()

StdProjectionMatrix StdProjectionMatrix::Scale ( float  sx,
float  sy,
float  sz 
)
static

Definition at line 384 of file StdMeshMath.cpp.

385 {
387  m.a[0][0] = sx; m.a[0][1] = 0.0f; m.a[0][2] = 0.0f; m.a[0][3] = 0.0f;
388  m.a[1][0] = 0.0f; m.a[1][1] = sy; m.a[1][2] = 0.0f; m.a[1][3] = 0.0f;
389  m.a[2][0] = 0.0f; m.a[2][1] = 0.0f; m.a[2][2] = sz; m.a[2][3] = 0.0f;
390  m.a[3][0] = 0.0f; m.a[3][1] = 0.0f; m.a[3][2] = 0.0f; m.a[3][3] = 1.0f;
391  return m;
392 }

◆ Translate()

StdProjectionMatrix StdProjectionMatrix::Translate ( float  dx,
float  dy,
float  dz 
)
static

Definition at line 374 of file StdMeshMath.cpp.

375 {
377  m.a[0][0] = 1.0f; m.a[0][1] = 0.0f; m.a[0][2] = 0.0f; m.a[0][3] = dx;
378  m.a[1][0] = 0.0f; m.a[1][1] = 1.0f; m.a[1][2] = 0.0f; m.a[1][3] = dy;
379  m.a[2][0] = 0.0f; m.a[2][1] = 0.0f; m.a[2][2] = 1.0f; m.a[2][3] = dz;
380  m.a[3][0] = 0.0f; m.a[3][1] = 0.0f; m.a[3][2] = 0.0f; m.a[3][3] = 1.0f;
381  return m;
382 }

Referenced by CStdGL::PerformMultiPix().

Here is the caller graph for this function:

◆ Upper3x4()

StdMeshMatrix StdProjectionMatrix::Upper3x4 ( const StdProjectionMatrix matrix)
static

Definition at line 433 of file StdMeshMath.cpp.

434 {
435  StdMeshMatrix m;
436  m(0, 0) = matrix.a[0][0]; m(0, 1) = matrix.a[0][1]; m(0, 2) = matrix.a[0][2]; m(0, 3) = matrix.a[0][3];
437  m(1, 0) = matrix.a[1][0]; m(1, 1) = matrix.a[1][1]; m(1, 2) = matrix.a[1][2]; m(1, 3) = matrix.a[1][3];
438  m(2, 0) = matrix.a[2][0]; m(2, 1) = matrix.a[2][1]; m(2, 2) = matrix.a[2][2]; m(2, 3) = matrix.a[2][3];
439  return m;
440 }

Referenced by CStdGL::SetupMultiBlt().

Here is the caller graph for this function:

Member Data Documentation

◆ NColumns

const int StdProjectionMatrix::NColumns = 4
static

Definition at line 122 of file StdMeshMath.h.

◆ NRows

const int StdProjectionMatrix::NRows = 4
static

Definition at line 123 of file StdMeshMath.h.


The documentation for this class was generated from the following files: