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>
127 lines
4.0 KiB
C++
127 lines
4.0 KiB
C++
//===========================================================================//
|
|
// File: gyro.hpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: Gyroscope -- the eye/body stabilisation subsystem //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(GYRO_HPP)
|
|
# define GYRO_HPP
|
|
|
|
# if !defined(POWERSUB_HPP)
|
|
# include <powersub.hpp>
|
|
# endif
|
|
|
|
//##################### Forward Class Declarations #######################
|
|
class Mech;
|
|
|
|
//###########################################################################
|
|
//################### Gyroscope Model Resource #########################
|
|
//###########################################################################
|
|
|
|
struct Gyroscope__SubsystemResource:
|
|
public PowerWatcher::SubsystemResource
|
|
{
|
|
Scalar reservedF4;
|
|
Scalar exageration;
|
|
Scalar maxAnimationNoise;
|
|
Scalar minAnimationNoise;
|
|
Scalar rotationPerSecond;
|
|
Scalar percentageOnNormal;
|
|
Scalar percentageOnDestruction;
|
|
Scalar percentageOnDegradation;
|
|
Scalar percentageOnFailure;
|
|
Vector3D springConstant;
|
|
Vector3D dampingConstant;
|
|
Vector3D posSpring;
|
|
Vector3D negSpring;
|
|
Vector3D rotationSpringConstant;
|
|
Vector3D rotationDampingConstant;
|
|
Vector3D rotationPosSpring;
|
|
Vector3D rotationNegSpring;
|
|
char eyeJoint[32];
|
|
char mechJoint[32];
|
|
Scalar collisionDamageMultiplier;
|
|
Scalar ballisticDamageMultiplier;
|
|
Scalar explosiveDamageMultiplier;
|
|
Scalar laserDamageMultiplier;
|
|
Scalar energyDamageMultiplier;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################## Gyroscope #############################
|
|
//###########################################################################
|
|
//
|
|
// The gyro drives the cockpit eye joint (view stabilisation) and the body
|
|
// lean. The tuning constants are read from the resource; the eye/body
|
|
// dynamics state (springs, forces, velocities, work matrices) is advanced by
|
|
// the per-frame GyroscopeSimulation and held in dynamicsState until that
|
|
// (staged) method is reconstructed with the named fields.
|
|
//
|
|
class Gyroscope:
|
|
public PowerWatcher
|
|
{
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
typedef void
|
|
(Gyroscope::*Performance)(Scalar time_slice);
|
|
void
|
|
SetPerformance(Performance performance)
|
|
{
|
|
Check(this);
|
|
activePerformance = (Simulation::Performance)performance;
|
|
}
|
|
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
void
|
|
ResetToInitialState();
|
|
void
|
|
GyroscopeSimulation(Scalar time_slice);
|
|
|
|
public:
|
|
typedef Gyroscope__SubsystemResource SubsystemResource;
|
|
|
|
Gyroscope(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
~Gyroscope();
|
|
|
|
protected:
|
|
Scalar exageration;
|
|
Scalar maxAnimationNoise;
|
|
Scalar minAnimationNoise;
|
|
Scalar rotationPerSecond;
|
|
Scalar percentageOnNormal;
|
|
Scalar percentageOnDestruction;
|
|
Scalar percentageOnDegradation;
|
|
Scalar percentageOnFailure;
|
|
Vector3D springConstant;
|
|
Vector3D dampingConstant;
|
|
Vector3D posSpring;
|
|
Vector3D negSpring;
|
|
Vector3D rotationSpringConstant;
|
|
Vector3D rotationDampingConstant;
|
|
Vector3D rotationPosSpring;
|
|
Vector3D rotationNegSpring;
|
|
Scalar damageMultiplier[5];
|
|
//
|
|
// Eye/body dynamics accumulators advanced by GyroscopeSimulation
|
|
// (positions, velocities, forces, clamps, work matrices, sway).
|
|
// Reserved until the per-frame sim is reconstructed (phase 5).
|
|
//
|
|
Scalar dynamicsState[64];
|
|
};
|
|
|
|
#endif
|