Files
TeslaRel410/restoration/source410/BT/MECHMPPR.HPP
T
CydandClaude Fable 5 eb8bba3195 BT410 Phase 5.3.6: look-button state machine -- full eyepoint composition
Reconstructs the binary's five-state LOOK machine (controls mapper tail,
part_013.c:396-459) as proper members/methods:

- MECHMPPR: LookState enum (None/Left/Right/Behind/Down) + lookState/
  previousLookState (out of reserved[24] -> [22]). InterpretControls picks the
  state from the look buttons each frame and on a CHANGE calls
  Mech::CommitLookState. BT_FORCE_LOOK=<1..4> dev hook.
- MECH: authored look angles lookLeft/Right/Front/BackAngle (deg->rad from the
  GameModel resource, guarded) + lookPitch/lookYaw + CommitLookState(int):
  side looks yaw by the authored angle, look-behind = yaw pi + lookBackAngle
  pitch, look-down = lookFrontAngle pitch, forward = identity. The per-frame
  eyepoint compose in Simulate adds the live Torso elevation on top.
  (reservedState [208] -> [202].)
- Deferred inside the commit (needs MechWeapon viewFireEnable/rearFiring):
  per-view weapon fire re-arm + HUD pip group-mask flip.

Verified headlessly: model reads clean authored angles (L=60 R=-60 F=-10 B=0
deg -- ModelResource layout confirmed again); BT_FORCE_LOOK=3 fires ONE commit
([look] state=3 yaw=3.14159 pitch=0) and the per-frame compose holds eyeYaw=pi
with eyePitch=0.349066 (lookBackAngle + the 20deg-clamped elevation). Zero Fail.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 22:08:50 -05:00

182 lines
5.6 KiB
C++

//===========================================================================//
// File: mechmppr.hpp //
// Project: BattleTech //
// Contents: Implementation details for the mech controls mapper //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(MECHMPPR_HPP)
# define MECHMPPR_HPP
# if !defined(SUBSYSTM_HPP)
# include <subsystm.hpp>
# endif
# if !defined(CSTR_HPP)
# include <cstr.hpp>
# endif
# if !defined(CONTROLS_HPP)
# include <controls.hpp>
# endif
# if !defined(VECTOR2D_HPP)
# include <vector2d.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//######################## MechControlsMapper ###########################
//###########################################################################
class MechControlsMapper:
public Subsystem
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static const IndexEntry AttributePointers[];
static AttributeIndexSet AttributeIndex;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute IDs -- the control inputs the streamed mappings bind to.
// The chain ends at Subsystem::NextAttributeID == 2.
//
public:
enum {
MechControlsMapperPadFirstAttributeID = 2,
StickPositionAttributeID, // 3
ThrottlePositionAttributeID, // 4
PedalsPositionAttributeID, // 5
ReverseThrustAttributeID, // 6
SpeedDemandAttributeID, // 7
TurnDemandAttributeID, // 8
LookForwardAttributeID, // 9
LookLeftAttributeID, // a
LookRightAttributeID, // b
LookBehindAttributeID, // c
LookDownAttributeID, // d
TorsoUpAttributeID, // e
TorsoDownAttributeID, // f
TorsoLeftAttributeID, // 10
TorsoRightAttributeID, // 11
TorsoCenterAttributeID, // 12
ControlModeAttributeID, // 13
DisplayModeAttributeID, // 14
PilotArrayPageAttributeID, // 15
PilotArrayAttributeID, // 16
NextAttributeID
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Control modes
//
public:
enum ControlMode {
BasicMode = 0,
StandardMode,
VeteranMode
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Look states. A five-state machine off the pod's look buttons; on a state
// change InterpretControls calls Mech::CommitLookState, which re-aims the
// eyepoint from the model's authored look angles (and, once the weapon wave
// lands, re-arms the per-view weapon fire enables).
//
public:
enum LookState {
LookNone = 0,
LookLeftState,
LookRightState,
LookBehindState,
LookDownState
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
MechControlsMapper(
Mech *owner,
int subsystem_ID,
CString subsystem_name,
RegisteredClass::ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechControlsMapper();
Logical
TestInstance() const;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Per-frame control interpretation (the mapper's Performance): reads the
// engine-pushed raw input attributes (throttle / stick / pedals / buttons)
// and publishes the locomotion + aim demands the mech drive consumes.
//
public:
typedef void
(MechControlsMapper::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
void
InterpretControls(Scalar time_slice);
Mech*
GetMech() { Check(this); return (Mech *)GetEntity(); }
Scalar
GetSpeedDemand() const { Check(this); return speedDemand; }
Scalar
GetTurnDemand() const { Check(this); return turnDemand; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data -- the published control inputs (the streamed mappings write
// these; InterpretControls, phase 5.3, reads them to drive the mech).
//
protected:
ControlsJoystick stickPosition;
Scalar throttlePosition;
Scalar pedalsPosition;
ControlsButton reverseThrust;
Scalar speedDemand;
Scalar turnDemand;
ControlsButton lookForward;
ControlsButton lookLeft;
ControlsButton lookRight;
ControlsButton lookBehind;
ControlsButton lookDown;
ControlsButton torsoUp;
ControlsButton torsoDown;
ControlsButton torsoLeft;
ControlsButton torsoRight;
ControlsButton torsoCenter;
int controlMode;
int displayMode;
int pilotArrayPage;
int pilotArray;
int lookState;
int previousLookState;
int reserved[22];
};
#endif