VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtProjectile Class Reference

Detailed Description

This class represents objects fired from weapons that follow ballistic trajectories, taking into account effects such as gravity and drag. Projectiles are updated each simulation frame to calculate their position based on physics, and can be used to detect collisions with terrain or other entities.

#include <projectile.h>

Inheritance diagram for makVre::DtProjectile:
[legend]

Classes

struct  ProjectileUpdateResult
 

Public Member Functions

 DtProjectile (const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL)
 
 DtProjectile (const DtSymbolString &name, DtReaderWriterRegistry *const parentRegistry=NULL)
 
 DtProjectile (const DtProjectile &orig, DtReaderWriterRegistry *const parentRegistry=NULL)
 
virtual ~DtProjectile () override
 
DtProjectileoperator= (const DtProjectile &orig)
 
virtual DtProjectileclone () const
 
bool operator== (const DtProjectile &) const
 
bool operator!= (const DtProjectile &rhs)
 
virtual DtString type () const
 
virtual DtProjectileDetonationResult update (double deltaTime)
 
virtual void setMunitionType (const DtEntityType &munitionType)
 
virtual void setCrossSection (double crossSection)
 
virtual void setDragCoefficient (double dragCoefficient)
 
virtual void setMass (double mass)
 
virtual void setMaxRange (double maxRange)
 
virtual void setPosition (DtVector position)
 
virtual void setVelocity (DtVector velocity)
 
virtual void setDistanceTraveled (double distanceTraveled)
 
virtual void setFiringEntity (DtSimObject *firingEntity)
 
virtual void setPhysicalWorld (DtPhysicalWorld *physicalWorld)
 
virtual const DtEntityType & munitionType ()
 
virtual DtVector velocity ()
 
virtual void putData (std::string &fp, int indentLevel=0) override
 
virtual DtlObjPtr getData (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
 

Static Public Member Functions

static void addProjectileCreatorFcn (const std::string &type, makVre::DtProjectileCreatorFcn fcn)
 
static DtProjectilecreateProjectile (DtlObjPtr mtlStream)
 
static DtProjectilecreateProjectile (const char *type, const char *pName, DtReaderWriterRegistry *const parentRegistry=NULL)
 
static DtProjectilecreator (const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL)
 
static DtProjectileFactoryfactory ()
 
static void setFactory (DtProjectileFactory *factory)
 

Protected Member Functions

 DtProjectile ()
 
virtual ProjectileUpdateResult updateProjectilePosition (double deltaTime)
 
virtual DtProjectileDetonationResult checkForProjectileCollision (const ProjectileUpdateResult &projectUpdateResult)
 

Protected Attributes

DtRwEntityType myMunitionType
 
DtRwReal myCrossSection
 
DtRwReal myDragCoefficient
 
DtRwReal myMass
 
DtRwReal myMaxRange
 
DtRwVector myPosition
 
DtRwVector myVelocity
 
DtRwReal myDistanceTraveled
 
DtSimObject * myFiringEntity
 
DtPhysicalWorld * myPhysicalWorld
 

Static Protected Attributes

static DtProjectileFactorytheFactory
 

Constructor & Destructor Documentation

◆ DtProjectile() [1/4]

makVre::DtProjectile::DtProjectile ( const DtString & name,
DtReaderWriterRegistry *const parentRegistry = NULL )

Constructor with string name.

Parameters
nameThe name of this projectile
parentRegistryParent registry for reader/writer functionality (optional)

Creates a new projectile with the specified name.

Referenced by clone(), createProjectile(), createProjectile(), creator(), DtProjectile(), operator!=(), operator=(), and operator==().

◆ DtProjectile() [2/4]

makVre::DtProjectile::DtProjectile ( const DtSymbolString & name,
DtReaderWriterRegistry *const parentRegistry = NULL )

Constructor with symbol string name.

Parameters
nameThe name of this projectile as a symbol string
parentRegistryParent registry for reader/writer functionality (optional)

Creates a new projectile with the specified name.

◆ DtProjectile() [3/4]

makVre::DtProjectile::DtProjectile ( const DtProjectile & orig,
DtReaderWriterRegistry *const parentRegistry = NULL )

Copy constructor.

Parameters
origThe source projectile to copy from
parentRegistryParent registry for reader/writer functionality (optional)

Creates a new projectile as a copy of the provided original.

References DtProjectile().

◆ ~DtProjectile()

virtual makVre::DtProjectile::~DtProjectile ( )
inlineoverridevirtual

Virtual destructor.

Cleans up resources used by the projectile.

◆ DtProjectile() [4/4]

makVre::DtProjectile::DtProjectile ( )
protected

Default constructor (not implemented)

Default constructor is protected and not implemented to prevent creation of instances without proper initialization.

Member Function Documentation

◆ operator=()

DtProjectile & makVre::DtProjectile::operator= ( const DtProjectile & orig)

Assignment operator.

Parameters
origThe source projectile to copy from
Returns
Reference to this projectile after assignment

Assigns the contents of the provided projectile to this one.

References DtProjectile().

◆ clone()

virtual DtProjectile * makVre::DtProjectile::clone ( ) const
virtual

Creates a clone of this projectile.

Returns
Pointer to a new projectile that is a clone of this one

Creates a new projectile as a deep copy of this one.

Reimplemented in DtCustomProjectile.

References DtProjectile().

◆ operator==()

bool makVre::DtProjectile::operator== ( const DtProjectile & ) const

Equality operator.

Parameters
otherThe projectile to compare with (unnamed parameter)
Returns
True if the projectiles are equal, false otherwise

Compares this projectile with another to determine if they are equal.

References DtProjectile().

◆ operator!=()

bool makVre::DtProjectile::operator!= ( const DtProjectile & rhs)
inline

Inequality operator.

Parameters
rhsThe projectile to compare with
Returns
True if the projectiles are not equal, false otherwise

Compares this projectile with another to determine if they are not equal.

References DtProjectile().

◆ type()

virtual DtString makVre::DtProjectile::type ( ) const
virtual

Returns the class type of projectile. Used to create the correct class type of projectile object on read from an mtl file. Derived classes should return their own unqiue type string to identify themselves. Returns DtProjectileType.

Reimplemented in DtCustomProjectile.

Referenced by addProjectileCreatorFcn(), and createProjectile().

◆ update()

virtual DtProjectileDetonationResult makVre::DtProjectile::update ( double deltaTime)
virtual

Updates the projectile's state for the current frame.

Parameters
deltaTimeTime elapsed since the last update in seconds
Returns
Result of the update, including detonation information if applicable

Updates the projectile's position and velocity based on physics calculations, and checks for collisions with terrain or entities. If a collision is detected, the returned result will contain information about the detonation.

Reimplemented in DtCustomProjectile.

◆ setMunitionType()

virtual void makVre::DtProjectile::setMunitionType ( const DtEntityType & munitionType)
virtual

Sets the munition type.

Parameters
munitionTypeThe DIS entity type of the munition

Sets the entity type that identifies this munition in DIS communications.

References munitionType().

◆ setCrossSection()

virtual void makVre::DtProjectile::setCrossSection ( double crossSection)
virtual

Sets the projectile cross-section.

Parameters
crossSectionThe cross-sectional area in square meters

Sets the cross-sectional area of the projectile, which affects drag calculations.

◆ setDragCoefficient()

virtual void makVre::DtProjectile::setDragCoefficient ( double dragCoefficient)
virtual

Sets the drag coefficient.

Parameters
dragCoefficientThe dimensionless drag coefficient

Sets the drag coefficient of the projectile, which affects how much air resistance slows down the projectile in flight.

◆ setMass()

virtual void makVre::DtProjectile::setMass ( double mass)
virtual

Sets the projectile mass.

Parameters
massThe mass in kilograms

Sets the mass of the projectile in kilograms, which affects trajectory calculations.

◆ setMaxRange()

virtual void makVre::DtProjectile::setMaxRange ( double maxRange)
virtual

Sets the maximum range.

Parameters
maxRangeThe maximum range in meters

Sets the maximum range the projectile can travel before being removed from the simulation.

◆ setPosition()

virtual void makVre::DtProjectile::setPosition ( DtVector position)
virtual

Sets the projectile position.

Parameters
positionThe position vector in local coordinates

Sets the current position of the projectile in local coordinates.

◆ setVelocity()

virtual void makVre::DtProjectile::setVelocity ( DtVector velocity)
virtual

Sets the projectile velocity.

Parameters
velocityThe velocity vector in meters per second

Sets the current velocity of the projectile in meters per second.

References velocity().

◆ setDistanceTraveled()

virtual void makVre::DtProjectile::setDistanceTraveled ( double distanceTraveled)
virtual

Sets the distance traveled.

Parameters
distanceTraveledThe distance traveled in meters

Sets the total distance the projectile has traveled since being fired.

◆ setFiringEntity()

virtual void makVre::DtProjectile::setFiringEntity ( DtSimObject * firingEntity)
virtual

Sets the firing entity.

Parameters
firingEntityPointer to the entity that fired this projectile

Sets the entity that fired this projectile.

◆ setPhysicalWorld()

virtual void makVre::DtProjectile::setPhysicalWorld ( DtPhysicalWorld * physicalWorld)
virtual

Sets the physical world.

Parameters
physicalWorldPointer to the physical world for terrain queries

Sets the physical world used for terrain queries and gravity direction.

◆ munitionType()

virtual const DtEntityType & makVre::DtProjectile::munitionType ( )
inlinevirtual

Gets the munition type.

Returns
Reference to the DIS entity type of the munition

Returns the entity type that identifies this munition in DIS communications.

References myMunitionType.

Referenced by setMunitionType().

◆ velocity()

virtual DtVector makVre::DtProjectile::velocity ( )
inlinevirtual

Gets the projectile velocity.

Returns
The current velocity vector in meters per second

Returns the current velocity of the projectile in meters per second.

References myVelocity.

Referenced by setVelocity().

◆ addProjectileCreatorFcn()

static void makVre::DtProjectile::addProjectileCreatorFcn ( const std::string & type,
makVre::DtProjectileCreatorFcn fcn )
static

Adds a given projectile creation function and corresponding type to the DtProjectileFactory.

References type().

◆ putData()

virtual void makVre::DtProjectile::putData ( std::string & fp,
int indentLevel = 0 )
overridevirtual

Overrides base class putData to output our type.

◆ getData()

virtual DtlObjPtr makVre::DtProjectile::getData ( DtlObjPtr args,
const DtReaderWriter::SearchPaths & searchPaths,
const DtVariableBindingsList & variableBindings )
overridevirtual

getData is just used to get us past the type in the data stream, since it's not actually stored.

◆ factory()

static DtProjectileFactory * makVre::DtProjectile::factory ( )
static

The factory for creating objects of type DtProjectile. The factory is used to generate projectiles on demand, when reading in from file (say from a process state repository entry in an order of battle file).

Referenced by setFactory().

◆ setFactory()

static void makVre::DtProjectile::setFactory ( DtProjectileFactory * factory)
static

The factory for creating objects of type DtProjectile. The factory is used to generate projectiles on demand, when reading in from file (say from a process state repository entry in an order of battle file).

References factory().

◆ createProjectile() [1/2]

static DtProjectile * makVre::DtProjectile::createProjectile ( DtlObjPtr mtlStream)
static

Creates and initializes a projectile when reading in from an MTL (MAK Technologies Lisp) file (i.e. an order of battle file).

Parameters
mtlStreamInput stream from an MTL file.
Returns
Newly created and initialized instance of this class, with data read in from the MTL stream.

References DtProjectile().

◆ createProjectile() [2/2]

static DtProjectile * makVre::DtProjectile::createProjectile ( const char * type,
const char * pName,
DtReaderWriterRegistry *const parentRegistry = NULL )
static

Creates and initializes a new instance of this class.

Parameters
typeThe projectile type identifier string
pNameDtReaderWriter name of the component
parentRegistryParent registry for reader/writer functionality (optional)
Returns
Newly created and initialized instance of this class

References DtProjectile(), and type().

◆ creator()

static DtProjectile * makVre::DtProjectile::creator ( const DtString & name,
DtReaderWriterRegistry *const parentRegistry = NULL )
static
Returns
Newly created instance of this class, with an empty DtReaderWriter name. Creation methods are registered with a DtComponentDescriptorFactory, so they can be created on demand as they are read in from a parameter database file.

References DtProjectile().

◆ updateProjectilePosition()

virtual ProjectileUpdateResult makVre::DtProjectile::updateProjectilePosition ( double deltaTime)
protectedvirtual

Updates the projectile's position based on physics.

Parameters
deltaTimeTime elapsed since the last update in seconds
Returns
Structure containing update results

Internal method that calculates the projectile's new position and velocity based on physics, including gravity and drag effects.

◆ checkForProjectileCollision()

virtual DtProjectileDetonationResult makVre::DtProjectile::checkForProjectileCollision ( const ProjectileUpdateResult & projectUpdateResult)
protectedvirtual

Checks if the projectile has collided with anything.

Parameters
projectUpdateResultResults from the position update
Returns
Information about the collision and detonation

Internal method that checks if the projectile has collided with terrain or entities based on its updated position.

Member Data Documentation

◆ myMunitionType

DtRwEntityType makVre::DtProjectile::myMunitionType
protected

The DIS entity type of the munition.

Stores the entity type that identifies this munition in DIS communications.

Referenced by munitionType().

◆ myCrossSection

DtRwReal makVre::DtProjectile::myCrossSection
protected

The cross-sectional area of the projectile.

Stores the cross-sectional area of the projectile in square meters, which affects drag calculations.

◆ myDragCoefficient

DtRwReal makVre::DtProjectile::myDragCoefficient
protected

The drag coefficient of the projectile.

Stores the dimensionless drag coefficient, which affects how much air resistance slows down the projectile in flight.

◆ myMass

DtRwReal makVre::DtProjectile::myMass
protected

The mass of the projectile in kilograms.

Stores the mass of the projectile, which affects trajectory calculations.

◆ myMaxRange

DtRwReal makVre::DtProjectile::myMaxRange
protected

The maximum range of the projectile in meters.

Stores the maximum range the projectile can travel before being removed from the simulation. This is technically a weapon property but is stored with the projectile to determine the maximum flight distance.

◆ myPosition

DtRwVector makVre::DtProjectile::myPosition
protected

The current position of the projectile.

Stores the current position of the projectile in local coordinates. This is updated every frame.

◆ myVelocity

DtRwVector makVre::DtProjectile::myVelocity
protected

The current velocity of the projectile.

Stores the current velocity of the projectile in meters per second. This is updated every frame based on physics calculations.

Referenced by velocity().

◆ myDistanceTraveled

DtRwReal makVre::DtProjectile::myDistanceTraveled
protected

The total distance the projectile has traveled.

Stores the total distance the projectile has traveled since being fired. This is used to test against the maximum range to determine when to remove the projectile if it hasn't collided with anything.

◆ myFiringEntity

DtSimObject* makVre::DtProjectile::myFiringEntity
protected

Pointer to the entity that fired this projectile.

Stores a pointer to the entity that fired this projectile.

◆ myPhysicalWorld

DtPhysicalWorld* makVre::DtProjectile::myPhysicalWorld
protected

Pointer to the physical world.

Stores a pointer to the physical world for terrain queries and to retrieve the world's gravity direction.

◆ theFactory

DtProjectileFactory* makVre::DtProjectile::theFactory
staticprotected

Factory for creating projectile instances.

Static pointer to the factory used to construct projectiles. Used to create the appropriate type of DtProjectile object when reading from files.


The documentation for this class was generated from the following file: