Files
TeslaRel410/CODE/RP/MUNGA/JOINT.HPP
T
CydandClaude Fable 5 fdd9ac9d97 Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)
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>
2026-07-02 13:21:58 -05:00

298 lines
7.1 KiB
C++

//============================================================================//
// File: joint.hh //
// Project: Munga // //
// Contents: Sets up Joint Subsystem //
// Definition of Class Joint //
//----------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ------------------------------------------------------------//
// 05/11/95 JM Initial coding. //
//----------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//============================================================================//
#if !defined JOINT_HPP
# define JOINT_HPP
# if !defined(SUBSYSTM_HPP)
# include <subsystm.hpp>
# endif
# if !defined(ROTATION_HPP)
# include <rotation.hpp>
# endif
# if !defined(MEMSTRM_HPP)
# include <memstrm.hpp>
# endif
//##################### Forward Class Declarations ##########################
class Entity;
class Joint;
class JointSubsystem;
//##########################################################################
//######################## BallTranslation ############################
//##########################################################################
class BallTranslation
{
friend class Joint;
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile BallTranslation *);
#endif
protected:
Point3D
jointTranslation;
EulerAngles
ballJoint;
const EulerAngles&
GetEulerAngles()
{Check(this); return ballJoint;}
const Point3D&
GetTranslation()
{Check(this); return jointTranslation;}
void
SetTranslation(const Point3D &new_trans)
{Check(this); jointTranslation = new_trans; }
void
SetEulerAngles(const EulerAngles &new_angles)
{Check(this); ballJoint = new_angles;}
BallTranslation();
BallTranslation(const BallTranslation &new_ball);
Logical
TestInstance() const;
BallTranslation&
operator=(const BallTranslation &new_ball)
{
ballJoint = new_ball.ballJoint;
jointTranslation = new_ball.jointTranslation;
return (*this);
}
};
//##########################################################################
//############################ Joint #################################
//##########################################################################
class Joint :
public Plug
{
friend class BallTranslation;
#if defined(USE_SIGNATURE)
friend int
Is_Signature_Bad(const volatile Joint *);
#endif
public:
enum JointType {
NULLJointType = -1,
HingeXJointType,
HingeYJointType,
HingeZJointType,
StaticJointType,
BallJointType,
BallTranslationJointType
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Constructors
//
public:
Joint(JointSubsystem *subsystem);
Joint(const Joint &new_joint);
Joint(
JointSubsystem *subsystem,
JointType joint_type
);
~Joint();
Joint&
operator=(const Joint &new_joint);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Joint Data
//
protected:
union {
EulerAngles *ballJoint;
Hinge *hingeJoint;
BallTranslation *ballTranslationJoint;
};
JointType
jointType;
Logical
jointModified;
JointSubsystem
*jointSubsystem;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Reading Joints
//
public:
const Hinge&
GetHinge()
{Check(this); return *hingeJoint;}
const EulerAngles&
GetEulerAngles();
const Point3D&
GetTranslation()
{
Check(this);
Verify(jointType == BallTranslationJointType);
return ballTranslationJoint->GetTranslation();
}
Radian
GetRadians() const
{
Check(this);
Verify (
(jointType == HingeXJointType ) ||
(jointType == HingeYJointType ) ||
(jointType == HingeZJointType )
);
return hingeJoint->rotationAmount;
}
JointType
GetJointType() const
{Check(this); return jointType; }
Logical
IsJointModified() const
{Check(this); return jointModified;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Writing Joints
//
public:
void
SetHinge(const Hinge &new_hinge);
void
SetRotation(const EulerAngles &new_angles);
void
SetRotation(const Radian &new_radian);
void
SetTranslation(const Point3D &new_trans);
void
JointModified(Logical new_value=True)
{Check(this); jointModified = new_value;}
};
//##############################################################################
//####################### Class JointSubsystem #################################
//##############################################################################
class JointSubsystem :
public Subsystem
{
friend Joint;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
typedef void
(JointSubsystem::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// local Support
//
public:
typedef TableOf<Joint*, int>
JointTable;
typedef TableIteratorOf<Joint*, int>
JointTableIterator;
Joint*
GetJoint(int joint_index)
{
Check(this);
JointTableIterator iterator(jointTable);
return iterator.GetNth(joint_index); }
void
AddJoint(
int joint_index,
Joint *new_joint
)
{Check(this); jointTable.AddValue(new_joint,joint_index);}
int
GetJointCount()
{
Check(this);
JointTableIterator iterator(jointTable);
return iterator.GetSize();
}
Logical
AreJointsModified()
{Check(this); return jointsModified;}
void
ModifyJoints(Logical modified=True)
{Check(this); jointsModified=modified;}
protected:
JointTable
jointTable;
Logical
jointsModified;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction / Destruction Support
//
public:
JointSubsystem(
Entity *owner,
int subsystem_ID,
SharedData &shared_data = DefaultData
);
~JointSubsystem();
void
InitializeJoint(int joint_index, Joint::JointType joint_type);
Logical
TestInstance() const;
};
#endif