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>
272 lines
5.5 KiB
C++
272 lines
5.5 KiB
C++
#pragma once
|
|
|
|
#include "subsystm.h"
|
|
#include "rotation.h"
|
|
#include "memstrm.h"
|
|
|
|
//##################### Forward Class Declarations ##########################
|
|
class Entity;
|
|
class Joint;
|
|
class JointSubsystem;
|
|
|
|
//##########################################################################
|
|
//######################## BallTranslation ############################
|
|
//##########################################################################
|
|
|
|
class BallTranslation
|
|
{
|
|
friend class Joint;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int
|
|
Is_Signature_Bad(const volatile BallTranslation *);
|
|
#endif
|
|
|
|
protected:
|
|
Point3D
|
|
jointTranslation;
|
|
EulerAngles
|
|
ballJoint;
|
|
|
|
const EulerAngles&
|
|
GetEulerAngles()
|
|
{Check(this); return ballJoint;}
|
|
const Point3D&
|
|
GetTranslation()
|
|
{Check(this); return jointTranslation;}
|
|
|
|
void
|
|
SetTranslation(const Point3D &new_trans)
|
|
{Check(this); jointTranslation = new_trans; }
|
|
void
|
|
SetEulerAngles(const EulerAngles &new_angles)
|
|
{Check(this); ballJoint = new_angles;}
|
|
|
|
BallTranslation();
|
|
BallTranslation(const BallTranslation &new_ball);
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
BallTranslation&
|
|
operator=(const BallTranslation &new_ball)
|
|
{
|
|
ballJoint = new_ball.ballJoint;
|
|
jointTranslation = new_ball.jointTranslation;
|
|
return (*this);
|
|
}
|
|
};
|
|
|
|
//##########################################################################
|
|
//############################ Joint #################################
|
|
//##########################################################################
|
|
|
|
class Joint :
|
|
public Plug
|
|
{
|
|
friend class BallTranslation;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int
|
|
Is_Signature_Bad(const volatile Joint *);
|
|
#endif
|
|
|
|
public:
|
|
enum JointType {
|
|
NULLJointType = -1,
|
|
HingeXJointType,
|
|
HingeYJointType,
|
|
HingeZJointType,
|
|
StaticJointType,
|
|
BallJointType,
|
|
BallTranslationJointType
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Constructors
|
|
//
|
|
public:
|
|
Joint(JointSubsystem *subsystem);
|
|
Joint(const Joint &new_joint);
|
|
Joint(
|
|
JointSubsystem *subsystem,
|
|
JointType joint_type
|
|
);
|
|
~Joint();
|
|
|
|
Joint&
|
|
operator=(const Joint &new_joint);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Joint Data
|
|
//
|
|
protected:
|
|
union {
|
|
EulerAngles *ballJoint;
|
|
Hinge *hingeJoint;
|
|
BallTranslation *ballTranslationJoint;
|
|
};
|
|
|
|
JointType
|
|
jointType;
|
|
Logical
|
|
jointModified;
|
|
JointSubsystem
|
|
*jointSubsystem;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Reading Joints
|
|
//
|
|
public:
|
|
const Hinge&
|
|
GetHinge()
|
|
{Check(this); return *hingeJoint;}
|
|
|
|
const EulerAngles&
|
|
GetEulerAngles();
|
|
|
|
const Point3D&
|
|
GetTranslation()
|
|
{
|
|
Check(this);
|
|
Verify(jointType == BallTranslationJointType);
|
|
return ballTranslationJoint->GetTranslation();
|
|
}
|
|
|
|
Radian
|
|
GetRadians() const
|
|
{
|
|
Check(this);
|
|
Verify (
|
|
(jointType == HingeXJointType ) ||
|
|
(jointType == HingeYJointType ) ||
|
|
(jointType == HingeZJointType )
|
|
);
|
|
return hingeJoint->rotationAmount;
|
|
}
|
|
|
|
JointType
|
|
GetJointType() const
|
|
{Check(this); return jointType; }
|
|
|
|
Logical
|
|
IsJointModified() const
|
|
{Check(this); return jointModified;}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Writing Joints
|
|
//
|
|
public:
|
|
void
|
|
SetHinge(const Hinge &new_hinge);
|
|
|
|
void
|
|
SetRotation(const EulerAngles &new_angles);
|
|
|
|
void
|
|
SetRotation(const Radian &new_radian);
|
|
|
|
void
|
|
SetTranslation(const Point3D &new_trans);
|
|
|
|
void
|
|
JointModified(Logical new_value=True)
|
|
{Check(this); jointModified = new_value;}
|
|
};
|
|
|
|
//##############################################################################
|
|
//####################### Class JointSubsystem #################################
|
|
//##############################################################################
|
|
|
|
class JointSubsystem :
|
|
public Subsystem
|
|
{
|
|
friend Joint;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Shared Data Support
|
|
//
|
|
public:
|
|
static Derivation *GetClassDerivations();
|
|
static SharedData DefaultData;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Model Support
|
|
//
|
|
typedef void
|
|
(JointSubsystem::*Performance)(Scalar time_slice);
|
|
|
|
void
|
|
SetPerformance(Performance performance)
|
|
{
|
|
Check(this);
|
|
activePerformance = (Simulation::Performance)performance;
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// local Support
|
|
//
|
|
public:
|
|
|
|
typedef TableOf<Joint*, int>
|
|
JointTable;
|
|
|
|
typedef TableIteratorOf<Joint*, int>
|
|
JointTableIterator;
|
|
|
|
Joint*
|
|
GetJoint(int joint_index)
|
|
{
|
|
Check(this);
|
|
JointTableIterator iterator(jointTable);
|
|
return iterator.GetNth(joint_index); }
|
|
|
|
void
|
|
AddJoint(
|
|
int joint_index,
|
|
Joint *new_joint
|
|
)
|
|
{Check(this); jointTable.AddValue(new_joint,joint_index);}
|
|
|
|
int
|
|
GetJointCount()
|
|
{
|
|
Check(this);
|
|
JointTableIterator iterator(jointTable);
|
|
return iterator.GetSize();
|
|
}
|
|
|
|
Logical
|
|
AreJointsModified()
|
|
{Check(this); return jointsModified;}
|
|
void
|
|
ModifyJoints(Logical modified=True)
|
|
{Check(this); jointsModified=modified;}
|
|
|
|
protected:
|
|
|
|
JointTable
|
|
jointTable;
|
|
Logical
|
|
jointsModified;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction / Destruction Support
|
|
//
|
|
|
|
public:
|
|
|
|
JointSubsystem(
|
|
Entity *owner,
|
|
int subsystem_ID,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
~JointSubsystem();
|
|
|
|
void
|
|
InitializeJoint(int joint_index, Joint::JointType joint_type);
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
};
|