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>
250 lines
7.5 KiB
C++
250 lines
7.5 KiB
C++
#pragma once
|
|
|
|
#include "..\munga\entity.h"
|
|
#include "..\munga\affnmtrx.h"
|
|
#include "..\munga\graph2d.h"
|
|
#include "..\munga\memstrm.h"
|
|
|
|
class L4GaugeImage;
|
|
class L4GaugeImageList;
|
|
class L4GaugeImagePrimitive;
|
|
|
|
class L4GaugeImageListResource;
|
|
class L4GaugeImagePrimitiveResource;
|
|
class L4GaugeImageResource;
|
|
|
|
|
|
|
|
//#######################################################################
|
|
// L4GaugeImage
|
|
//#######################################################################
|
|
class L4GaugeImage SIGNATURED
|
|
{
|
|
public:
|
|
//--------------------------------------------------------------------
|
|
// Create L4GaugeImage from memory stream
|
|
//--------------------------------------------------------------------
|
|
L4GaugeImage(MemoryStream *mem_stream);
|
|
|
|
static L4GaugeImage *Make(const char *file_name);
|
|
static L4GaugeImage *Make(ResourceDescription::ResourceID new_resource_id);
|
|
//--------------------------------------------------------------------
|
|
// Destructor
|
|
//--------------------------------------------------------------------
|
|
~L4GaugeImage();
|
|
//--------------------------------------------------------------------
|
|
// TestInstance
|
|
//--------------------------------------------------------------------
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//--------------------------------------------------------------------
|
|
// CreateL4GaugeImageStream
|
|
//--------------------------------------------------------------------
|
|
static ResourceDescription::ResourceID
|
|
CreateL4GaugeImageStream(
|
|
ResourceFile *resource_file,
|
|
const char *model_name,
|
|
NotationFile *model_file,
|
|
const ResourceDirectories *directories
|
|
);
|
|
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
void
|
|
Draw(
|
|
Scalar LOD_value, // smaller = more detail (1.0 = 'normal')
|
|
Scalar scale_value, // metersPerPixel
|
|
GraphicsView *graphics_view,
|
|
int default_color,
|
|
AffineMatrix &localToView,
|
|
int boxed_color = 0
|
|
);
|
|
|
|
protected:
|
|
static Logical
|
|
MemoryStreamWrite(
|
|
MemoryStream *mem_stream,
|
|
NotationFile *gim_file
|
|
);
|
|
|
|
//====================================================================
|
|
// Protected data
|
|
//====================================================================
|
|
int
|
|
vertexCount, // number of vertices in vertexArray
|
|
LODCount; // number of seperate LOD's
|
|
Point3D
|
|
*vertexArray; // pointer to array of vertices
|
|
Scalar
|
|
*LODScales; // pointer to array of scalar 'scale' values
|
|
L4GaugeImageList
|
|
**LODList;
|
|
// LODList points to an array of pointers to
|
|
// L4GaugeImageLists.
|
|
};
|
|
|
|
//#######################################################################
|
|
// L4GaugeImageList
|
|
//#######################################################################
|
|
class L4GaugeImageList SIGNATURED
|
|
{
|
|
friend class L4GaugeImage;
|
|
|
|
protected:
|
|
//--------------------------------------------------------------------
|
|
// Create L4GaugeList from memory stream
|
|
//--------------------------------------------------------------------
|
|
L4GaugeImageList(MemoryStream *mem_stream);
|
|
|
|
//--------------------------------------------------------------------
|
|
// Destructor
|
|
//--------------------------------------------------------------------
|
|
~L4GaugeImageList();
|
|
//--------------------------------------------------------------------
|
|
// TestInstance
|
|
//--------------------------------------------------------------------
|
|
Logical
|
|
TestInstance() const;
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
static Logical
|
|
MemoryStreamWrite(
|
|
MemoryStream *mem_stream,
|
|
NotationFile *gim_file,
|
|
const char *page_name
|
|
);
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
void
|
|
Draw(
|
|
GraphicsView *graphics_view,
|
|
int default_color,
|
|
AffineMatrix &localToView,
|
|
Point3D *untransformed_vertex_array,
|
|
Point3D *transformed_vertex_array,
|
|
Logical *transformed_flag_array,
|
|
Scalar scale_factor,
|
|
int boxed_color
|
|
);
|
|
|
|
//====================================================================
|
|
// Protected data
|
|
//====================================================================
|
|
int
|
|
primitiveCount; // number of primitives in primitiveList
|
|
L4GaugeImagePrimitive
|
|
**primitiveList;
|
|
// primitiveList points to an array of pointers to
|
|
// L4GaugeImagePrimitives.
|
|
};
|
|
|
|
//#######################################################################
|
|
// L4GaugeImagePrimitive
|
|
//#######################################################################
|
|
class L4GaugeImagePrimitive SIGNATURED
|
|
{
|
|
friend class L4GaugeImageList;
|
|
|
|
protected:
|
|
//--------------------------------------------------------------------
|
|
// Create L4GaugeImagePrimitive from memory stream
|
|
//--------------------------------------------------------------------
|
|
L4GaugeImagePrimitive(MemoryStream *mem_stream);
|
|
static int
|
|
CreateL4GaugeImagePrimitiveResource(
|
|
NotationFile *gim_file,
|
|
const char *gim_name,
|
|
const ResourceDirectories *directories,
|
|
char *primitive_data,
|
|
L4GaugeImagePrimitiveResource *prim_res
|
|
);
|
|
|
|
//--------------------------------------------------------------------
|
|
// Destructor
|
|
//--------------------------------------------------------------------
|
|
~L4GaugeImagePrimitive();
|
|
//--------------------------------------------------------------------
|
|
// TestInstance
|
|
//--------------------------------------------------------------------
|
|
Logical
|
|
TestInstance() const;
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
static Logical
|
|
MemoryStreamWrite(
|
|
MemoryStream *mem_stream,
|
|
const char *type_name,
|
|
const char *data
|
|
);
|
|
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
void
|
|
Draw(
|
|
GraphicsView *graphics_view,
|
|
int default_color,
|
|
AffineMatrix &localToView,
|
|
Point3D *untransformed_vertex_array,
|
|
Point3D *transformed_vertex_array,
|
|
Logical *transformed_flag_array,
|
|
Scalar scale_factor,
|
|
Rectangle2D *bounds
|
|
);
|
|
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
void
|
|
TransformVertex(
|
|
AffineMatrix &local_to_view,
|
|
Point3D &untransformed_vertex,
|
|
Point3D *transformed_vertex,
|
|
Logical &transformed_flag,
|
|
Scalar scale_factor,
|
|
Rectangle2D *bounds
|
|
);
|
|
|
|
//--------------------------------------------------------------------
|
|
// These are the supported attribute types.
|
|
//--------------------------------------------------------------------
|
|
enum
|
|
{
|
|
attributeNormal=0,
|
|
attributeUnscaled=0x0001
|
|
};
|
|
//--------------------------------------------------------------------
|
|
// These are the supported primitive types.
|
|
//--------------------------------------------------------------------
|
|
enum primitiveType
|
|
{
|
|
primitiveVector=0,
|
|
numberOfTypes
|
|
};
|
|
|
|
//====================================================================
|
|
// Protected data
|
|
//====================================================================
|
|
int
|
|
attributes, // general attributes
|
|
color; // a specially parsed attribute
|
|
|
|
primitiveType
|
|
type; // the primitive's type
|
|
|
|
union
|
|
{
|
|
//--------------------------------
|
|
// type = primitiveVector
|
|
//--------------------------------
|
|
struct
|
|
{
|
|
int
|
|
indexCount, // the number of indices
|
|
*indexList; // pointer to an array of indices
|
|
}
|
|
vector;
|
|
}
|
|
data;
|
|
|
|
};
|