|
VR-Engage
2.2
|
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>
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 |
| DtProjectile & | operator= (const DtProjectile &orig) |
| virtual DtProjectile * | clone () 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 DtProjectile * | createProjectile (DtlObjPtr mtlStream) |
| static DtProjectile * | createProjectile (const char *type, const char *pName, DtReaderWriterRegistry *const parentRegistry=NULL) |
| static DtProjectile * | creator (const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL) |
| static DtProjectileFactory * | factory () |
| 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 DtProjectileFactory * | theFactory |
| makVre::DtProjectile::DtProjectile | ( | const DtString & | name, |
| DtReaderWriterRegistry *const | parentRegistry = NULL ) |
Constructor with string name.
| name | The name of this projectile |
| parentRegistry | Parent 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==().
| makVre::DtProjectile::DtProjectile | ( | const DtSymbolString & | name, |
| DtReaderWriterRegistry *const | parentRegistry = NULL ) |
Constructor with symbol string name.
| name | The name of this projectile as a symbol string |
| parentRegistry | Parent registry for reader/writer functionality (optional) |
Creates a new projectile with the specified name.
| makVre::DtProjectile::DtProjectile | ( | const DtProjectile & | orig, |
| DtReaderWriterRegistry *const | parentRegistry = NULL ) |
Copy constructor.
| orig | The source projectile to copy from |
| parentRegistry | Parent registry for reader/writer functionality (optional) |
Creates a new projectile as a copy of the provided original.
References DtProjectile().
|
inlineoverridevirtual |
Virtual destructor.
Cleans up resources used by the projectile.
|
protected |
Default constructor (not implemented)
Default constructor is protected and not implemented to prevent creation of instances without proper initialization.
| DtProjectile & makVre::DtProjectile::operator= | ( | const DtProjectile & | orig | ) |
Assignment operator.
| orig | The source projectile to copy from |
Assigns the contents of the provided projectile to this one.
References DtProjectile().
|
virtual |
Creates a clone of this projectile.
Creates a new projectile as a deep copy of this one.
Reimplemented in DtCustomProjectile.
References DtProjectile().
| bool makVre::DtProjectile::operator== | ( | const DtProjectile & | ) | const |
Equality operator.
| other | The projectile to compare with (unnamed parameter) |
Compares this projectile with another to determine if they are equal.
References DtProjectile().
|
inline |
Inequality operator.
| rhs | The projectile to compare with |
Compares this projectile with another to determine if they are not equal.
References DtProjectile().
|
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().
|
virtual |
Updates the projectile's state for the current frame.
| deltaTime | Time elapsed since the last update in seconds |
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.
|
virtual |
Sets the munition type.
| munitionType | The DIS entity type of the munition |
Sets the entity type that identifies this munition in DIS communications.
References munitionType().
|
virtual |
Sets the projectile cross-section.
| crossSection | The cross-sectional area in square meters |
Sets the cross-sectional area of the projectile, which affects drag calculations.
|
virtual |
Sets the drag coefficient.
| dragCoefficient | The dimensionless drag coefficient |
Sets the drag coefficient of the projectile, which affects how much air resistance slows down the projectile in flight.
|
virtual |
Sets the projectile mass.
| mass | The mass in kilograms |
Sets the mass of the projectile in kilograms, which affects trajectory calculations.
|
virtual |
Sets the maximum range.
| maxRange | The maximum range in meters |
Sets the maximum range the projectile can travel before being removed from the simulation.
|
virtual |
Sets the projectile position.
| position | The position vector in local coordinates |
Sets the current position of the projectile in local coordinates.
|
virtual |
Sets the projectile velocity.
| velocity | The velocity vector in meters per second |
Sets the current velocity of the projectile in meters per second.
References velocity().
|
virtual |
Sets the distance traveled.
| distanceTraveled | The distance traveled in meters |
Sets the total distance the projectile has traveled since being fired.
|
virtual |
Sets the firing entity.
| firingEntity | Pointer to the entity that fired this projectile |
Sets the entity that fired this projectile.
|
virtual |
Sets the physical world.
| physicalWorld | Pointer to the physical world for terrain queries |
Sets the physical world used for terrain queries and gravity direction.
|
inlinevirtual |
Gets the munition type.
Returns the entity type that identifies this munition in DIS communications.
References myMunitionType.
Referenced by setMunitionType().
|
inlinevirtual |
Gets the projectile velocity.
Returns the current velocity of the projectile in meters per second.
References myVelocity.
Referenced by setVelocity().
|
static |
Adds a given projectile creation function and corresponding type to the DtProjectileFactory.
References type().
|
overridevirtual |
Overrides base class putData to output our type.
|
overridevirtual |
getData is just used to get us past the type in the data stream, since it's not actually stored.
|
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().
|
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().
|
static |
Creates and initializes a projectile when reading in from an MTL (MAK Technologies Lisp) file (i.e. an order of battle file).
| mtlStream | Input stream from an MTL file. |
References DtProjectile().
|
static |
Creates and initializes a new instance of this class.
| type | The projectile type identifier string |
| pName | DtReaderWriter name of the component |
| parentRegistry | Parent registry for reader/writer functionality (optional) |
References DtProjectile(), and type().
|
static |
References DtProjectile().
|
protectedvirtual |
Updates the projectile's position based on physics.
| deltaTime | Time elapsed since the last update in seconds |
Internal method that calculates the projectile's new position and velocity based on physics, including gravity and drag effects.
|
protectedvirtual |
Checks if the projectile has collided with anything.
| projectUpdateResult | Results from the position update |
Internal method that checks if the projectile has collided with terrain or entities based on its updated position.
|
protected |
The DIS entity type of the munition.
Stores the entity type that identifies this munition in DIS communications.
Referenced by munitionType().
|
protected |
The cross-sectional area of the projectile.
Stores the cross-sectional area of the projectile in square meters, which affects drag calculations.
|
protected |
The drag coefficient of the projectile.
Stores the dimensionless drag coefficient, which affects how much air resistance slows down the projectile in flight.
|
protected |
The mass of the projectile in kilograms.
Stores the mass of the projectile, which affects trajectory calculations.
|
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.
|
protected |
The current position of the projectile.
Stores the current position of the projectile in local coordinates. This is updated every frame.
|
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().
|
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.
|
protected |
Pointer to the entity that fired this projectile.
Stores a pointer to the entity that fired this projectile.
|
protected |
Pointer to the physical world.
Stores a pointer to the physical world for terrain queries and to retrieve the world's gravity direction.
|
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.