Files
BT412/engine/MUNGA/LINMTRX.cpp
T
arcattackandClaude Opus 4.8 7b7d465e5e Initial commit: bt411 -- standalone Windows BattleTech (Tesla 4.10 port)
Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.

Layout:
  engine/   MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
            work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
            models) + image codec; the minimal rp/ headers the audio HAL needs
  game/     reconstructed BT logic + surviving-original BT source + fwd shims
            + WinMain launcher
  content/  full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
  docs/     format specs + reconstruction ledgers
  reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
  tools/    MP console emulator + map/resource scanners

One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:03:40 -05:00

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