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>
146 lines
3.2 KiB
C++
146 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "point3d.h"
|
|
|
|
class Origin;
|
|
class TransposedMatrix;
|
|
class Hinge;
|
|
class EulerAngles;
|
|
class Quaternion;
|
|
class YawPitchRoll;
|
|
|
|
class AffineMatrix
|
|
{
|
|
public:
|
|
static const AffineMatrix Identity;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int Is_Signature_Bad(const volatile AffineMatrix *);
|
|
#endif
|
|
|
|
Scalar entries[12];
|
|
|
|
//
|
|
// Constructors
|
|
//
|
|
AffineMatrix() {}
|
|
AffineMatrix& BuildIdentity();
|
|
AffineMatrix(int) { BuildIdentity(); }
|
|
|
|
//
|
|
// Assignment Operators
|
|
//
|
|
AffineMatrix& operator=(const AffineMatrix &m);
|
|
AffineMatrix& operator=(const Origin &p);
|
|
AffineMatrix& operator=(const Hinge &hinge);
|
|
AffineMatrix& operator=(const EulerAngles &angles);
|
|
AffineMatrix& operator=(const YawPitchRoll &angles);
|
|
AffineMatrix& operator=(const Quaternion &q);
|
|
AffineMatrix& operator=(const Point3D &p) { return SetFromAxis(W_Axis, p); }
|
|
AffineMatrix& operator=(const Matrix4x4 &m);
|
|
AffineMatrix& operator=(const TransposedMatrix &m);
|
|
|
|
//
|
|
// Comparison operators
|
|
//
|
|
Logical operator==(const AffineMatrix& m) const;
|
|
Logical operator!=(const AffineMatrix& m) const;
|
|
|
|
//
|
|
// Index operators
|
|
//
|
|
Scalar& operator()(size_t row, size_t column)
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(row>3);
|
|
Warn(column>2);
|
|
return entries[(column<<2)+row];
|
|
}
|
|
const Scalar& operator()(size_t row, size_t column) const
|
|
{
|
|
Check_Pointer(this);
|
|
Warn(row>3);
|
|
Warn(column>2);
|
|
return entries[(column<<2)+row];
|
|
}
|
|
|
|
//
|
|
// Axis Manipulation functions
|
|
//
|
|
void GetFromAxis(size_t index, Vector3D *v) const;
|
|
void GetToAxis(size_t index, Vector3D *v) const;
|
|
|
|
AffineMatrix& SetFromAxis(size_t index, const Vector3D &v);
|
|
AffineMatrix& SetToAxis(size_t index, const Vector3D &v);
|
|
|
|
//
|
|
// Matrix Multiplication
|
|
//
|
|
AffineMatrix& Multiply(const AffineMatrix& m1, const AffineMatrix& m2);
|
|
AffineMatrix& operator*=(const AffineMatrix& m)
|
|
{
|
|
AffineMatrix temp(*this);
|
|
return Multiply(temp,m);
|
|
}
|
|
|
|
//
|
|
// Matrix Inversion
|
|
//
|
|
AffineMatrix& Invert(const AffineMatrix& Source);
|
|
AffineMatrix& Invert()
|
|
{
|
|
AffineMatrix src(*this);
|
|
return Invert(src);
|
|
}
|
|
|
|
//
|
|
// Scaling, Rotation and Translation
|
|
//
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Vector3D &v);
|
|
AffineMatrix& operator*=(const Vector3D &v)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,v);
|
|
}
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Quaternion &q);
|
|
AffineMatrix& operator*=(const Quaternion &q)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,q);
|
|
}
|
|
AffineMatrix& Multiply(const AffineMatrix &m,const Point3D &p);
|
|
AffineMatrix& operator*=(const Point3D& p)
|
|
{
|
|
AffineMatrix m(*this);
|
|
return Multiply(m,p);
|
|
}
|
|
|
|
//
|
|
// Miscellaneous Functions
|
|
//
|
|
Scalar Determinant() const;
|
|
AffineMatrix& Solve();
|
|
|
|
//
|
|
// Support functions
|
|
//
|
|
friend std::ostream& operator <<(std::ostream& stream, const AffineMatrix& m);
|
|
Logical TestInstance() const;
|
|
static Logical TestClass();
|
|
};
|
|
|
|
inline Point3D& Point3D::operator=(const AffineMatrix& m)
|
|
{
|
|
m.GetFromAxis(W_Axis,this);
|
|
return *this;
|
|
}
|
|
|
|
inline MemoryStream& MemoryStream_Read(MemoryStream *stream, AffineMatrix *output)
|
|
{
|
|
return stream->ReadBytes(output, sizeof(*output));
|
|
}
|
|
inline MemoryStream& MemoryStream_Write(MemoryStream *stream, const AffineMatrix *input)
|
|
{
|
|
return stream->WriteBytes(input, sizeof(*input));
|
|
}
|