Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
139 lines
3.0 KiB
C++
139 lines
3.0 KiB
C++
#include "munga.h"
|
|
#pragma hdrstop
|
|
|
|
#include "linmtrx.h"
|
|
#include "matrix.h"
|
|
#include "linmtrx.h"
|
|
|
|
const LinearMatrix LinearMatrix::Identity(true);
|
|
|
|
LinearMatrix&
|
|
LinearMatrix::operator=(const AffineMatrix &m)
|
|
{
|
|
//
|
|
// Make sure to test linearness on m
|
|
//
|
|
AffineMatrix::operator=(m);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//###########################################################################
|
|
//###########################################################################
|
|
//
|
|
LinearMatrix&
|
|
LinearMatrix::operator=(const Matrix4x4 &m)
|
|
{
|
|
//
|
|
// Make sure to test linearness on m
|
|
//
|
|
AffineMatrix::operator=(m);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//###########################################################################
|
|
//###########################################################################
|
|
//
|
|
LinearMatrix&
|
|
LinearMatrix::operator=(const TransposedMatrix &m)
|
|
{
|
|
//
|
|
// Make sure to test linearness on m
|
|
//
|
|
AffineMatrix::operator=(m);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//###########################################################################
|
|
//###########################################################################
|
|
//
|
|
LinearMatrix&
|
|
LinearMatrix::Invert(const LinearMatrix& Source)
|
|
{
|
|
|
|
//
|
|
//-----------------------------------------
|
|
// First, transpose the 3x3 rotation matrix
|
|
//-----------------------------------------
|
|
//
|
|
(*this)(0,0) = Source(0,0);
|
|
(*this)(0,1) = Source(1,0);
|
|
(*this)(0,2) = Source(2,0);
|
|
(*this)(1,0) = Source(0,1);
|
|
(*this)(1,1) = Source(1,1);
|
|
(*this)(1,2) = Source(2,1);
|
|
(*this)(2,0) = Source(0,2);
|
|
(*this)(2,1) = Source(1,2);
|
|
(*this)(2,2) = Source(2,2);
|
|
|
|
//
|
|
//----------------------------
|
|
// Now run the offsets through
|
|
//----------------------------
|
|
//
|
|
(*this)(3,0) =
|
|
-Source(3,0)*Source(0,0)
|
|
-Source(3,1)*Source(0,1)
|
|
-Source(3,2)*Source(0,2);
|
|
(*this)(3,1) =
|
|
-Source(3,0)*Source(1,0)
|
|
-Source(3,1)*Source(1,1)
|
|
-Source(3,2)*Source(1,2);
|
|
(*this)(3,2) =
|
|
-Source(3,0)*Source(2,0)
|
|
-Source(3,1)*Source(2,1)
|
|
-Source(3,2)*Source(2,2);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//###########################################################################
|
|
//###########################################################################
|
|
//
|
|
LinearMatrix&
|
|
LinearMatrix::Normalize()
|
|
{
|
|
(*this)(0,2) = (*this)(1,0)*(*this)(2,1) - (*this)(1,1)*(*this)(2,0);
|
|
(*this)(1,2) = (*this)(2,0)*(*this)(0,1) - (*this)(2,1)*(*this)(0,0);
|
|
(*this)(2,2) = (*this)(0,0)*(*this)(1,1) - (*this)(0,1)*(*this)(1,0);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//###########################################################################
|
|
//###########################################################################
|
|
//
|
|
Logical
|
|
LinearMatrix::TestInstance() const
|
|
{
|
|
UnitVector v1;
|
|
GetFromAxis(X_Axis,&v1);
|
|
if (!v1.TestInstance())
|
|
{
|
|
Dump(*this);
|
|
Dump(v1);
|
|
return False;
|
|
}
|
|
|
|
UnitVector v2;
|
|
GetFromAxis(Y_Axis,&v2);
|
|
if (!v2.TestInstance())
|
|
{
|
|
Dump(*this);
|
|
Dump(v1);
|
|
return False;
|
|
}
|
|
|
|
UnitVector v3;
|
|
v3.Vector3D::Cross(v1,v2);
|
|
GetFromAxis(Z_Axis,&v1);
|
|
return Close_Enough(v1,v3);
|
|
}
|
|
|
|
#if defined(TEST_CLASS)
|
|
#include "linmtrx.tcp"
|
|
#endif
|
|
|