Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
155 lines
4.3 KiB
C++
155 lines
4.3 KiB
C++
//===========================================================================//
|
|
// File: vtvpwr.cc //
|
|
// Project: Red Planet //
|
|
// Contents: Implementation details of vectored thrust vehicles //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 01/23/95 JMA Initial coding. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <rp.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(VTVPWR_HPP)
|
|
# include <vtvpwr.hpp>
|
|
#endif
|
|
|
|
#if !defined(THRUSTER_HPP)
|
|
# include <thruster.hpp>
|
|
#endif
|
|
|
|
#if !defined(VTV_HPP)
|
|
# include <vtv.hpp>
|
|
#endif
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
VTVPower::SharedData
|
|
VTVPower::DefaultData(
|
|
VTVPower::ClassDerivations,
|
|
VTVPower::MessageHandlers,
|
|
VTVPower::AttributeIndex,
|
|
VTVPower::StateCount
|
|
);
|
|
|
|
Derivation
|
|
VTVPower::ClassDerivations(
|
|
Subsystem::ClassDerivations,
|
|
"VTVPower"
|
|
);
|
|
|
|
//#############################################################################
|
|
// Attribute Support
|
|
//
|
|
const VTVPower::IndexEntry
|
|
VTVPower::AttributePointers[]=
|
|
{
|
|
ATTRIBUTE_ENTRY(VTVPower, MaxAccelerationOutput, maxAccelerationOutput)
|
|
};
|
|
|
|
VTVPower::AttributeIndexSet
|
|
VTVPower::AttributeIndex(
|
|
ELEMENTS(VTVPower::AttributePointers),
|
|
VTVPower::AttributePointers,
|
|
Subsystem::AttributeIndex
|
|
);
|
|
|
|
//#############################################################################
|
|
// Model Support
|
|
//
|
|
void
|
|
VTVPower::PowerSimulation(Scalar)
|
|
{
|
|
Check(this);
|
|
|
|
//
|
|
//--------------------------------------------------------------------------
|
|
// Get pointers to the other subsystems we will have to deal with inside the
|
|
// VTV
|
|
//--------------------------------------------------------------------------
|
|
//
|
|
VTV* vtv = GetEntity();
|
|
Check(vtv);
|
|
Scalar average_moment_arm = 0.0f;
|
|
|
|
//
|
|
//---------------------------------------
|
|
// Find out the average moment arm length
|
|
//---------------------------------------
|
|
//
|
|
JointSubsystem *joint_subsystem = vtv->GetJointSubsystem();
|
|
Check(joint_subsystem);
|
|
Verify(joint_subsystem->GetJointCount());
|
|
|
|
int i;
|
|
for (i=0; i<MAX_THRUSTERS; ++i)
|
|
{
|
|
Thruster* thruster =
|
|
(Thruster*) vtv->GetSubsystem(VTV::Thruster1Subsystem + i);
|
|
|
|
if(thruster != NULL)
|
|
{
|
|
average_moment_arm += thruster->momentArmLength;
|
|
}
|
|
}
|
|
average_moment_arm /= joint_subsystem->GetJointCount();
|
|
Scalar average_accel = maxAccelerationOutput / joint_subsystem->GetJointCount();
|
|
Check_Fpu();
|
|
|
|
for (i=0; i<MAX_THRUSTERS; ++i)
|
|
{
|
|
Thruster* thruster =
|
|
(Thruster*) vtv->GetSubsystem(VTV::Thruster1Subsystem + i);
|
|
|
|
if(thruster != NULL)
|
|
{
|
|
Check(thruster);
|
|
Verify(!Small_Enough(thruster->momentArmLength));
|
|
thruster->powerScale = average_moment_arm / thruster->momentArmLength;
|
|
thruster->currentAcceleration = average_accel * thruster->powerScale;
|
|
}
|
|
}
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
VTVPower::VTVPower(
|
|
VTV *entity,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource
|
|
):
|
|
Subsystem(entity, subsystem_ID, subsystem_resource, DefaultData)
|
|
{
|
|
if (entity->GetInstance() != VTV::ReplicantInstance)
|
|
{
|
|
SetPerformance(&VTVPower::PowerSimulation);
|
|
}
|
|
|
|
maxAccelerationOutput = subsystem_resource->maxAcceleration;
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
VTVPower::~VTVPower()
|
|
{
|
|
Check(this);
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
VTVPower::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|