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>
181 lines
4.1 KiB
C++
181 lines
4.1 KiB
C++
#pragma once
|
|
|
|
#include "scalar.h"
|
|
#include <D3DX9.h>
|
|
|
|
class AffineMatrix;
|
|
class TransposedMatrix;
|
|
class Origin;
|
|
class Hinge;
|
|
class EulerAngles;
|
|
class YawPitchRoll;
|
|
class Point3D;
|
|
class Quaternion;
|
|
|
|
class AbstractMatrix4x4
|
|
{
|
|
public:
|
|
Scalar entries[16];
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int Is_Signature_Bad(const volatile AbstractMatrix4x4 *);
|
|
#endif
|
|
|
|
AbstractMatrix4x4& operator=(const AbstractMatrix4x4& m);
|
|
|
|
Logical TestInstance() const;
|
|
|
|
protected:
|
|
AbstractMatrix4x4() {}
|
|
AbstractMatrix4x4& Transpose(const AbstractMatrix4x4 &m);
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Matrix4x4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
class Matrix4x4 : public AbstractMatrix4x4
|
|
{
|
|
public:
|
|
static const Matrix4x4 Identity;
|
|
|
|
Matrix4x4() {}
|
|
Matrix4x4& BuildIdentity();
|
|
Matrix4x4(int) { BuildIdentity(); }
|
|
|
|
Matrix4x4& operator=(const Matrix4x4 &m)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&m);
|
|
AbstractMatrix4x4::operator=(m);
|
|
return *this;
|
|
}
|
|
Matrix4x4& operator=(const TransposedMatrix &m);
|
|
Matrix4x4& operator=(const AffineMatrix &m);
|
|
Matrix4x4& operator=(const Origin &p);
|
|
Matrix4x4& operator=(const Hinge &hinge);
|
|
Matrix4x4& operator=(const EulerAngles &angles);
|
|
Matrix4x4& operator=(const YawPitchRoll &angles);
|
|
Matrix4x4& operator=(const D3DXMATRIX &m);
|
|
Matrix4x4& BuildRotation(const Quaternion &q);
|
|
Matrix4x4& operator=(const Quaternion &q);
|
|
Matrix4x4& BuildTranslation(const Point3D &p);
|
|
Matrix4x4& operator=(const Point3D &p);
|
|
|
|
//
|
|
// Index operators
|
|
// Note that Matrix4x4 is stored in row major format, not column major,
|
|
// although they are indexed the same
|
|
//
|
|
Scalar& operator ()(size_t Row,size_t Column)
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(Row>3);
|
|
Warn(Column>3);
|
|
return entries[(Row<<2)+Column];
|
|
}
|
|
const Scalar& operator ()(size_t Row,size_t Column) const
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(Row>3);
|
|
Warn(Column>3);
|
|
return entries[(Row<<2)+Column];
|
|
}
|
|
|
|
Matrix4x4& Multiply(const Matrix4x4& Source1, const Matrix4x4& Source2);
|
|
Matrix4x4& operator *=(const Matrix4x4& m)
|
|
{
|
|
Matrix4x4 temp(*this);
|
|
return Multiply(temp,m);
|
|
}
|
|
Matrix4x4& Multiply(const Matrix4x4& Source1, const AffineMatrix &Source2);
|
|
Matrix4x4& operator *=(const AffineMatrix& m)
|
|
{
|
|
Matrix4x4 temp(*this);
|
|
return Multiply(temp,m);
|
|
}
|
|
Matrix4x4& Multiply(const AffineMatrix &Source1, const Matrix4x4& Source2);
|
|
Matrix4x4& Multiply(const AffineMatrix &Source1, const AffineMatrix &Source2);
|
|
|
|
#if 0
|
|
Matrix4x4& Invert(const Matrix4x4& Source);
|
|
Matrix4x4& Invert()
|
|
{
|
|
Matrix4x4 src(*this);
|
|
return Invert(src);
|
|
}
|
|
#endif
|
|
|
|
Matrix4x4& SetToProjection(Scalar Z_Plane, Scalar Inv_Q, Scalar Dx, Scalar Dy, Scalar Dz);
|
|
Matrix4x4& SetToPerspectiveProjection(Scalar Distance)
|
|
{
|
|
Verify(Distance != 0.0);
|
|
return SetToProjection(0.0, 1.0 / Distance, 0.0, 0.0, -1.0);
|
|
}
|
|
Matrix4x4& SetToOrthogonalProjection() { return SetToProjection(0.0, 0.0, 0.0, 0.0, -1.0); }
|
|
|
|
D3DXMATRIX ToD3DMatrix();
|
|
|
|
friend std::ostream& operator <<(std::ostream& stream, const Matrix4x4& Matrix4x4);
|
|
static Logical TestClass();
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Matrix4x4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
class TransposedMatrix : public AbstractMatrix4x4
|
|
{
|
|
public:
|
|
//
|
|
// Constructors
|
|
//
|
|
TransposedMatrix() {}
|
|
|
|
//
|
|
// Assignment operators
|
|
//
|
|
TransposedMatrix& operator=(const Matrix4x4 &m)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&m);
|
|
AbstractMatrix4x4::Transpose(m);
|
|
return *this;
|
|
}
|
|
TransposedMatrix& operator=(const TransposedMatrix &m)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&m);
|
|
AbstractMatrix4x4::operator=(m);
|
|
return *this;
|
|
}
|
|
TransposedMatrix& operator=(const AffineMatrix &m);
|
|
|
|
//
|
|
// Index operators
|
|
//
|
|
Scalar& operator()(size_t Row,size_t Column)
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(Row>3);
|
|
Warn(Column>3);
|
|
return entries[(Column<<2)+Row];
|
|
}
|
|
const Scalar& operator()(size_t Row,size_t Column) const
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(Row>3);
|
|
Warn(Column>3);
|
|
return entries[(Column<<2)+Row];
|
|
}
|
|
|
|
//
|
|
// Support Functions
|
|
//
|
|
friend std::ostream& operator <<(std::ostream& stream, const TransposedMatrix& Matrix4x4);
|
|
};
|
|
|
|
inline Matrix4x4& Matrix4x4::operator=(const TransposedMatrix &m)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&m);
|
|
AbstractMatrix4x4::Transpose(m);
|
|
return *this;
|
|
}
|