Mech phase 2: reconstruct Gyroscope (: PowerWatcher) -- Mech gyroSubsystem
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>
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
//===========================================================================//
|
||||
// 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");
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
//===========================================================================//
|
||||
// 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
|
||||
Reference in New Issue
Block a user