Mech phase 2: reconstruct Torso (: PowerWatcher) -- Mech sinkSourceSubsystem
Torso twist / weapon-elevation subsystem. Named tuning members (rates/limits in radians, button-accel) + twist/elevation dynamics pad; ctor chains PowerWatcher, copies tuning (RAD_PER_DEG), skips skeleton-joint resolution (deferred to the live Mech link). statics/dtor/test real; TorsoSimulation/TorsoCopySimulation staged. Cockpit leaf trio complete (Gyroscope/HUD/Torso). BT: 30 ok. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
//===========================================================================//
|
||||
// File: torso.cpp //
|
||||
// Project: BattleTech Brick: Mech subsystems //
|
||||
// Contents: Torso -- torso twist / weapon elevation //
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
||||
// All Rights reserved worldwide //
|
||||
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
||||
//===========================================================================//
|
||||
|
||||
#include <bt.hpp>
|
||||
#pragma hdrstop
|
||||
|
||||
#if !defined(TORSO_HPP)
|
||||
# include <torso.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(MECH_HPP)
|
||||
# include <mech.hpp>
|
||||
#endif
|
||||
|
||||
Derivation
|
||||
Torso::ClassDerivations(
|
||||
PowerWatcher::ClassDerivations,
|
||||
"Torso"
|
||||
);
|
||||
|
||||
Torso::SharedData
|
||||
Torso::DefaultData(
|
||||
Torso::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
Torso::Torso(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *r,
|
||||
SharedData &shared_data
|
||||
):
|
||||
PowerWatcher(owner, subsystem_ID, r, shared_data)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(r);
|
||||
|
||||
isDamagedCopy = (owner->GetInstance() == Entity::ReplicantInstance);
|
||||
|
||||
statusFlags = 0;
|
||||
buttonAccelerationPerSecond = r->buttonAccelerationPerSecond;
|
||||
buttonAccelerationStart = r->buttonAccelerationStartValue;
|
||||
|
||||
baseTwistRate = r->horizontalRotationPerSecond * RAD_PER_DEG;
|
||||
baseElevationRate = r->verticalRotationPerSecond * RAD_PER_DEG;
|
||||
horizontalLimitRight= r->horizontalLimitRight * RAD_PER_DEG;
|
||||
horizontalLimitLeft = r->horizontalLimitLeft * RAD_PER_DEG;
|
||||
verticalLimitTop = r->verticalLimitTop * RAD_PER_DEG;
|
||||
verticalLimitBottom = r->verticalLimitBottom * RAD_PER_DEG;
|
||||
|
||||
twistCenterHigh = verticalLimitTop;
|
||||
twistCenterLow = verticalLimitBottom;
|
||||
elevationCenter = verticalLimitTop;
|
||||
elevationHalfBottom = verticalLimitBottom * 0.5f;
|
||||
|
||||
buttonRampActive = 0;
|
||||
buttonRamp = 0.0f;
|
||||
horizontalEnabled = r->torsoHorizontalEnabled;
|
||||
|
||||
//
|
||||
// The named skeleton joints are resolved once the Mech skeleton link is
|
||||
// live (per-frame sim / phase-4 wiring); leave the handles null here.
|
||||
//
|
||||
horizontalJointNode = NULL;
|
||||
horizontalShadowJointNode = NULL;
|
||||
|
||||
currentTwist = 0.0f;
|
||||
currentElevation = 0.0f;
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
dynamicsState[i] = 0.0f;
|
||||
}
|
||||
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
Torso::~Torso()
|
||||
{
|
||||
}
|
||||
|
||||
Logical
|
||||
Torso::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
Torso::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
//
|
||||
// Per-frame torso twist / elevation integration. Not yet reconstructed.
|
||||
//
|
||||
void
|
||||
Torso::TorsoSimulation(Scalar)
|
||||
{
|
||||
Fail("Torso::TorsoSimulation -- torso.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
void
|
||||
Torso::TorsoCopySimulation(Scalar)
|
||||
{
|
||||
Fail("Torso::TorsoCopySimulation -- torso.cpp not yet reconstructed");
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
//===========================================================================//
|
||||
// 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;
|
||||
|
||||
//###########################################################################
|
||||
//##################### 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 { return currentTwist; }
|
||||
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;
|
||||
void *horizontalJointNode;
|
||||
void *horizontalShadowJointNode;
|
||||
Scalar currentTwist;
|
||||
Scalar currentElevation;
|
||||
//
|
||||
// Twist/elevation dynamics accumulators advanced by TorsoSimulation.
|
||||
// Reserved until the per-frame sim is reconstructed (phase 5).
|
||||
//
|
||||
Scalar dynamicsState[24];
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user