Eye/body stabilisation subsystem. Full resource struct + tuning members (springs/damping/noise/percentages/damage multipliers) reconstructed; the eye/body dynamics accumulators held in a reserved pad until the per-frame GyroscopeSimulation is reconstructed (phase 5). Ctor chains PowerWatcher + copies tuning; statics/dtor/test/reset real; sim staged. BT: 28 ok. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
118 lines
3.0 KiB
C++
118 lines
3.0 KiB
C++
//===========================================================================//
|
|
// File: gyro.cpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: Gyroscope -- eye/body stabilisation //
|
|
//---------------------------------------------------------------------------//
|
|
// 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(GYRO_HPP)
|
|
# include <gyro.hpp>
|
|
#endif
|
|
|
|
#if !defined(MECH_HPP)
|
|
# include <mech.hpp>
|
|
#endif
|
|
|
|
Derivation
|
|
Gyroscope::ClassDerivations(
|
|
PowerWatcher::ClassDerivations,
|
|
"Gyroscope"
|
|
);
|
|
|
|
Gyroscope::SharedData
|
|
Gyroscope::DefaultData(
|
|
Gyroscope::ClassDerivations,
|
|
Subsystem::MessageHandlers,
|
|
Subsystem::AttributeIndex,
|
|
Subsystem::StateCount
|
|
);
|
|
|
|
Gyroscope::Gyroscope(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *r,
|
|
SharedData &shared_data
|
|
):
|
|
PowerWatcher(owner, subsystem_ID, r, shared_data)
|
|
{
|
|
Check(owner);
|
|
Check_Pointer(r);
|
|
|
|
exageration = r->exageration;
|
|
maxAnimationNoise = r->maxAnimationNoise;
|
|
minAnimationNoise = r->minAnimationNoise;
|
|
rotationPerSecond = r->rotationPerSecond;
|
|
percentageOnNormal = r->percentageOnNormal;
|
|
percentageOnDestruction = r->percentageOnDestruction;
|
|
percentageOnDegradation = r->percentageOnDegradation;
|
|
percentageOnFailure = r->percentageOnFailure;
|
|
|
|
springConstant = r->springConstant;
|
|
dampingConstant = r->dampingConstant;
|
|
posSpring = r->posSpring;
|
|
negSpring = r->negSpring;
|
|
rotationSpringConstant = r->rotationSpringConstant;
|
|
rotationDampingConstant = r->rotationDampingConstant;
|
|
rotationPosSpring = r->rotationPosSpring;
|
|
rotationNegSpring = r->rotationNegSpring;
|
|
|
|
damageMultiplier[0] = r->collisionDamageMultiplier;
|
|
damageMultiplier[1] = r->ballisticDamageMultiplier;
|
|
damageMultiplier[2] = r->explosiveDamageMultiplier;
|
|
damageMultiplier[3] = r->laserDamageMultiplier;
|
|
damageMultiplier[4] = r->energyDamageMultiplier;
|
|
|
|
//
|
|
// Zero the eye/body dynamics accumulators (the binary zeroes each; the
|
|
// per-frame sim seeds them from the springs above).
|
|
//
|
|
for (int i = 0; i < 64; ++i)
|
|
{
|
|
dynamicsState[i] = 0.0f;
|
|
}
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
Gyroscope::~Gyroscope()
|
|
{
|
|
}
|
|
|
|
Logical
|
|
Gyroscope::TestClass(Mech &)
|
|
{
|
|
return True;
|
|
}
|
|
|
|
Logical
|
|
Gyroscope::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|
|
void
|
|
Gyroscope::ResetToInitialState()
|
|
{
|
|
Check(this);
|
|
for (int i = 0; i < 64; ++i)
|
|
{
|
|
dynamicsState[i] = 0.0f;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Per-frame eye/body stabilisation (spring/damper integration driving the
|
|
// cockpit eye joint). Not yet reconstructed.
|
|
//
|
|
void
|
|
Gyroscope::GyroscopeSimulation(Scalar)
|
|
{
|
|
Fail("Gyroscope::GyroscopeSimulation -- gyro.cpp not yet reconstructed");
|
|
}
|