Reconstructs the shared skeleton-joint resolver and binds the first subsystem (Torso) to the live skeleton. - Mech::ResolveJoint(name) (mech.cpp @00424b60): GetSegment(name) -> segment joint index -> GetJointSubsystem()->GetJoint(idx). - Verified the JointedMover base streams the full skeleton headlessly: jointCount=19, 40 named segments (gun joints jointlgun/jointrgun, shoulders, hip, leg joints jointlthigh..jointrankle). BT_MECH_LOG [skel] summary; BT_SKEL_DUMP lists every segment/jointIdx. - Torso resolves + binds its twist joint (ResolveJoint(torsoHorizontalJoint)) and pushes currentTwist onto it via Joint::SetRotation (hinge->Radian, ball->EulerAngles yaw). The TEST.EGG mech has a fixed torso (horizJoint='', enabled=0) so its twist path is inert -- correct + guarded, zero Fail. Next joint piece: elevation -> gun joints (jointlgun/jointrgun, the fixed-torso aim mechanism) via weapon-joint binding; then gait leg animation. Both are VISIBLE only under the renderer; headlessly the joint transforms are loggable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
135 lines
4.2 KiB
C++
135 lines
4.2 KiB
C++
//===========================================================================//
|
|
// File: torso.hpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: Torso -- the torso twist / weapon-elevation subsystem //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(TORSO_HPP)
|
|
# define TORSO_HPP
|
|
|
|
# if !defined(POWERSUB_HPP)
|
|
# include <powersub.hpp>
|
|
# endif
|
|
|
|
//##################### Forward Class Declarations #######################
|
|
class Mech;
|
|
class Joint;
|
|
|
|
//###########################################################################
|
|
//##################### Torso Model Resource ###########################
|
|
//###########################################################################
|
|
|
|
struct Torso__SubsystemResource:
|
|
public PowerWatcher::SubsystemResource
|
|
{
|
|
Scalar horizontalRotationPerSecond;
|
|
Scalar verticalRotationPerSecond;
|
|
Scalar horizontalLimitRight;
|
|
Scalar horizontalLimitLeft;
|
|
Scalar verticalLimitTop;
|
|
Scalar verticalLimitBottom;
|
|
char torsoHorizontalJoint[32];
|
|
char torsoHorizontalShadowJoint[32];
|
|
Logical torsoHorizontalEnabled;
|
|
Scalar buttonAccelerationPerSecond;
|
|
Scalar buttonAccelerationStartValue;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################### Torso ################################
|
|
//###########################################################################
|
|
//
|
|
// Drives torso twist (horizontal) and weapon elevation (vertical). The
|
|
// tuning rates/limits come from the resource; the live twist/elevation state
|
|
// and the resolved skeleton joints are advanced by the per-frame
|
|
// TorsoSimulation (staged) once the Mech skeleton link is live.
|
|
//
|
|
class Torso:
|
|
public PowerWatcher
|
|
{
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
typedef void
|
|
(Torso::*Performance)(Scalar time_slice);
|
|
void
|
|
SetPerformance(Performance performance)
|
|
{
|
|
Check(this);
|
|
activePerformance = (Simulation::Performance)performance;
|
|
}
|
|
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
Scalar
|
|
CurrentTwist() const { Check(this); return currentTwist; }
|
|
Scalar
|
|
CurrentElevation() const { Check(this); return currentElevation; }
|
|
Logical
|
|
GetHorizontalEnabled() const{ Check(this); return horizontalEnabled; }
|
|
|
|
//
|
|
// Analog aim inputs (written by MechControlsMapper::InterpretControls;
|
|
// consumed by TorsoSimulation to slew the twist/elevation each frame).
|
|
//
|
|
void
|
|
SetAnalogElevationAxis(Scalar axis) { Check(this); analogElevationAxis = axis; }
|
|
void
|
|
SetAnalogTwistAxis(Scalar axis) { Check(this); analogTwistAxis = axis; }
|
|
|
|
void
|
|
TorsoSimulation(Scalar time_slice);
|
|
void
|
|
TorsoCopySimulation(Scalar time_slice);
|
|
|
|
public:
|
|
typedef Torso__SubsystemResource SubsystemResource;
|
|
|
|
Torso(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
~Torso();
|
|
|
|
protected:
|
|
int isDamagedCopy;
|
|
int statusFlags;
|
|
Logical horizontalEnabled;
|
|
Scalar baseTwistRate;
|
|
Scalar baseElevationRate;
|
|
Scalar horizontalLimitRight;
|
|
Scalar horizontalLimitLeft;
|
|
Scalar verticalLimitTop;
|
|
Scalar verticalLimitBottom;
|
|
Scalar twistCenterHigh;
|
|
Scalar twistCenterLow;
|
|
Scalar elevationCenter;
|
|
Scalar elevationHalfBottom;
|
|
Scalar buttonAccelerationPerSecond;
|
|
Scalar buttonAccelerationStart;
|
|
int buttonRampActive;
|
|
Scalar buttonRamp;
|
|
Joint *horizontalJointNode;
|
|
Joint *horizontalShadowJointNode;
|
|
Scalar currentTwist;
|
|
Scalar currentElevation;
|
|
Scalar analogElevationAxis;
|
|
Scalar analogTwistAxis;
|
|
//
|
|
// Twist/elevation dynamics accumulators advanced by TorsoSimulation.
|
|
// Reserved until the per-frame sim is reconstructed (phase 5).
|
|
//
|
|
Scalar dynamicsState[22];
|
|
};
|
|
|
|
#endif
|