The mech now drives from the authentic control chain (faithful route). Verified headlessly: full throttle -> walks straight at top speed (30 u/s) along heading; throttle+turn -> walks a circle (radius = speed/turnRate); neutral -> holds pose; zero Fail. MechControlsMapper::InterpretControls (mechmppr.cpp @004afd10) -- installed as the mapper's per-frame Performance (roster slot 0, ticks before the mech): - speedDemand = topSpeed*throttle*fwdScale (reverse inverts); soft stick (square) / pedal (cube) response; Basic=stick turn, Std/Vet=pedal turn; speed clamped while turning hard. Reads owner stride via Mech accessors. - BT_FORCE_THROTTLE/BT_FORCE_TURN dev hooks for headless verification. Mech::Simulate drive -- consumes the mapper demands: - accelerate currentBodySpeed toward speedDemand (maxBodyAcceleration); - authTurnRate = lerp(walkingTurnRate, runningTurnRate) by ground speed + over-run falloff (mech4.cpp master-perf @0x4aa3d3); - integrate heading via Quaternion::Add(prevPose, (0,turn*rate*dt,0)); - facing = world -Z basis (GetFromAxis(Z_Axis)); worldLinearVelocity = facing*spd; - integrate position (increment-1 core). MECH.HPP: 9 named locomotion members out of reservedState (now [211]) -- walking/runningTurnRate, reverse/walkStrideLength, reverseSpeedMax, forwardThrottleScale, maxBodyAcceleration, body/currentBodySpeed. BRING-UP DEFAULTS (authentic values come from the model resource + LoadLocomotionClips -- next refinement). Deferred: gait-clip-exact advance + leg anim (needs animation subsystem/renderer), model-resource sourcing, terrain drop, torso/free-look aim, telemetry filters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
165 lines
5.0 KiB
C++
165 lines
5.0 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
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// 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 reserved[24];
|
|
};
|
|
|
|
#endif
|