VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ballisticGun.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 #pragma once
11 
16 #include "vrfcore/timer.h"
17 #include "vrfutil/simMunition.h"
18 
21 class DtVrfBalGunPSR;
23 class DtIntegerInputPort;
25 class DtBooleanInputPort;
26 class DtAnalogInputPort;
27 class DtInputPortGroup;
28 
29 #define DEBUG_MUZZLE_POSITION 0
30 
44 {
45 
46 public:
47 
50  DtBallisticGun(const DtString& name,
51  DtLocalObject* owner,
52  DtSimulationServices* simManager,
53  DtComponentDescriptor* desc = 0,
54  DtReaderWriterRegistry* parentRegistry = 0);
55 
56 
58  virtual ~DtBallisticGun() override;
59 
60  virtual bool init() override;
61 
68  virtual void initPendingDetonations();
69 
72  virtual const char* type() const override;
73 
75  virtual void preFirstTickInit() override;
76 
81  virtual void tick() override;
82 
89  virtual void fire(int roundsToFire, bool computePHit);
90 
104  virtual bool checkHitProbability(const DtEntityType& type, DtReal
105  range, bool& probabilityEntryFound, int burstSize = 1);
106 
109  virtual double hitProbabilityModifier(const DtEntityType& type,
110  DtReal range, int burstSize = 1);
111 
115  virtual double targetMotionHitModifier(const DtEntityType& type, DtReal
116  range);
117 
120  virtual double selfMotionHitModifier(const DtEntityType& type, DtReal
121  range);
122 
125  virtual double skillLevelModifier(const double range);
126 
130  virtual double lifeformPostureModifier();
131 
135  virtual double burstSizeModifier(int burstSize);
136 
144  virtual makVrfEvents::DtFireEvent * createFireInteraction(const int rounds);
145 
166  virtual makVrfEvents::DtDetonationEvent * createDetonationInteraction(
167  int burstSize,
168  DtTime& detTime, bool& isHit,
169  bool assureMiss = false);
170 
185  bool computeBallisticElevationAngle(const DtVector& localMuzzlePosition,
186  const DtVector& localImpactPosition,
187  double minElevation, double maxElevation,
188  const DtEntityType& munitionType,
189  double& angleOut, DtString& reasonOut) const;
190 
199  virtual void computeBallisticMuzzleVelocity(const DtVector& localMuzzlePosition,
200  const DtVector& localImpactPosition,
201  DtVector& geocentricMuzzleVelocity) const;
202 
213  virtual void getMissLocation(DtVector gunPosition,
214  const DtSimObject *intendedTarget, double muzzleSpeed,
215  DtVector& missLocation, DtVector& velocityVector,
216  DtDetonationResult& detonationResult,
217  DtSimObjectReference* target, bool allowHitIntendedTarget);
218 
233  virtual void scheduleDetonation(makVrfEvents::DtDetonationEvent * detInter,
234  DtTime detTime);
235 
236  virtual DtString probabilityString() const;
237 
239  virtual DtVector calculateMuzzlePosition() const;
240 
241  virtual DtVector calculateGunOffset() const;
242 
248  virtual makVrfEvents::DtDetonationEvent * createDetonationInteraction(
249  const DtDetonationDescriptor& desc, DtTime& detTime);
250 
253  virtual DtDetonationDescriptor* createDetonationDescriptor(
254  makVrfEvents::DtDetonationEvent* detInter, DtTime simTime);
255 
258  virtual double maxGunRange() const;
259 
260 #if DEBUG_MUZZLE_POSITION
261  virtual bool taskVisualizationsActive() const { return true; };
262 #endif
263 
264 public:
265 
273  static void detonationCallback(DtTimer * timer);
274 
279  static void setTracerUseCallback(DtSimMessage * msg, void *component);
280  virtual void processSetTracerUse(DtSimMessage* msg);
282 
283  static DtReaderWriter* getMuzzlePositionAttribute(void *ctrlr);
284  virtual DtReaderWriter* getMuzzlePositionAttribute();
285 
289  static DtSimComponent * creator(const DtString& name,
290  DtLocalObject* owner,
291  DtSimulationServices* simManager,
292  DtComponentDescriptor* desc = 0,
293  DtReaderWriterRegistry* parentRegistry = 0);
294 
295 protected:
296 
298  virtual bool createPortGroups() override;
299 
301  virtual bool createPorts() override;
302 
308  virtual bool createPSR();
309 
314  virtual void processSimObjectAdded(DtSimObjectReference vrfObject);
315 
317  virtual void addRangeItems();
318 
322  virtual void addAdditionalWeaponRangeItems();
323 
326  virtual bool aimGun();
327 
335  virtual void spawnFlyoutMunition(const DtVector& geocentricMuzzlePosition,
336  const DtVector& geocentricMuzzleVelocity,
337  const DtEntityType& munitionEntityType,
338  const DtString& eventId);
339 
345  virtual DtEntityType munitionType(DtSimMunition& munitionEntry);
346 
347 #if DEBUG_MUZZLE_POSITION
348  virtual void updateTaskVisualizations();
349 #endif
350 
351 protected:
352 
354  DtBallisticGun();
355 
357  DtBallisticGun(const DtBallisticGun & orig);
358 
360  const DtBallisticGun & operator=(const DtBallisticGun & orig);
361 
362 protected:
364 
369 
371  DtVector myMuzzleOffset;
372 
377 
378  DtList myTimerList;
379  DtArtPartType myGunArtPart;
381 
385 
388 
392 
400 
410 
417 
427 
437 
439 
440  boost::signals2::scoped_connection mySimObjectAddedConnection;
441 
445 };
446 
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
DtAnalogInputPort * myAimElevationInputPort
Input Port Name: aim-elevation Input Port Description: Externally-supplied elevation angle (radians...
Definition: ballisticGun.h:436
boost::signals2::scoped_connection mySimObjectAddedConnection
Definition: ballisticGun.h:440
Instances of DtTimer are used to maintain the information needed to represent some kind of scheduled ...
Definition: timer.h:38
Contains class declarations for DtAmmunitionInputPort, DtAmmunitionOutputPort, and DtAmmunitionPortDa...
Definition: ammunitionIOPort.h:28
virtual bool taskVisualizationsActive() const
Returns true if task visualizations are currently active for this component. Default behavior is to r...
const DtActuatorComponent & operator=(const DtActuatorComponent &orig)
assignment operator
DtReal myMuzzleSpeed
Definition: ballisticGun.h:370
DtVector myMuzzleOffset
Definition: ballisticGun.h:371
Definition: fireEvent.h:16
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
DtVrfBalGunPSR * myProcessState
Container for state data associated with this component. This state is saved and restored as part of ...
Definition: ballisticGun.h:384
DtBallisticGun provides a simple model of a ballistic gun.
Definition: ballisticGun.h:43
DtReal myMaxGunRange
This max gun range is determined by the P(hit) tables. It is computed once at init time and saved for...
Definition: ballisticGun.h:368
DtString myCurrentEventId
Definition: ballisticGun.h:380
Definition: readerWriter.h:85
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Definition: readerWriterRegistry.h:39
DtBooleanInputPort * myLoadedPort
Input Port Name: loaded Input Port Description: Must be True for gun to fire. Input Port Range: Inpu...
Definition: ballisticGun.h:416
This file contains the class declaration for the.
Definition: detonationEvent.h:20
Contains class declarations for DtIntegerInputPort, DtIntegerOutputPort, and DtIntegerPortData.
Definition: integerIOPort.h:25
End User Description: DtActuator is the base class for all actuator model components. Developer Description: The DtActuator base class caches a pointer to the entity's radio for convenience. Derived classes may have articulated parts that are configured from the DtActuatorComponentDescriptor's DtSimArtPartDescriptorList. For each articulated part in the list a DtArticulatedPartStateRepository will be created to store the data for the part such as it's location, rotation and so forth. These are created in the entity's DtVrfObjectStateRepository createParts() function. This call creates all the attached parts for all the actuators. These articulated state repositories are managed by the DtAttachmentManager. They are cached by their partType which is the DIS Enumeration describing the part from the disEnums.h file and was specified in the actuator's DtActuatorComponentDescriptor as descriped above. The partType is used as the category of the DtEntityType used to look up articulated parts in the DtAttachementManager. When an actuator needs access to a particular articulated part it looks it up by the part's object type.
Definition: actuatorComponent.h:47
DtPlatformLocalObjectFacade myPlatformLocalObjectFacade
Member to allow for access to platform specific data.
Definition: ballisticGun.h:443
DtBallisticGunDescriptor; a descriptor for the DtBallisticGun component.
Definition: ballisticGunDescriptor.h:38
DtArtPartType myGunArtPart
Definition: ballisticGun.h:379
DtMovementSimObjectFacade myCurrentTargetSimObjectFacade
Definition: ballisticGun.h:444
DtIntegerInputPort * myQuantityInputPort
Input Port Name: quantity Input Port Description: Indicates the number of rounds to be fired with a s...
Definition: ballisticGun.h:409
virtual void updateTaskVisualizations()
Called to update task visualizations after every tick. Implemented by subclasses. ...
Definition: simComponent.h:471
class DtDetonationDescriptor:
Definition: detonationDescriptor.h:33
File: simMsg.h.
Definition: simMessage.h:35
virtual bool init() override
Overridden to cache a pointer to the entity's radio in this class.
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation frame...
Contains class declarations for DtBooleanInputPort, DtBooleanOutputPort, and DtBooleanPortData.
Definition: boolIOPort.h:25
virtual bool createPorts()
Called by init. Derived classes should override this method to create all their input/output ports an...
DtList myTimerList
Definition: ballisticGun.h:378
virtual bool createPortGroups()
Called by init. Derived classes should override this method to create all their input/output port gro...
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:97
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
DtInputPortGroup * myBalGunControlPortGroup
Input Port Group Name: gun-control Input Port Group Description:
Definition: ballisticGun.h:391
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:80
DtReal myCurrentRange
Definition: ballisticGun.h:376
DtInputPortGroup is a data port group of a data consumer. It may contain any number of DtInputPorts a...
Definition: inputPortGroup.h:35
Contains class declarations for DtAnalogInputPort, DtAnalogOutputPort, and DtAnalogPortData.
Definition: analogIOPort.h:25
DtBallisticGunDescriptor * myBalGunDescriptor
Definition: ballisticGun.h:363
DtSimObjectReference myCurrentTarget
These are set by createFireInteraction and used by createDetonationInteraction.
Definition: ballisticGun.h:375
DtBooleanInputPort * myTriggerPort
Input Port Name: trigger Input Port Description: Edge-triggered input which fires a round whenever a ...
Definition: ballisticGun.h:399
DtSimMunition class.
Definition: simMunition.h:31
Class DtVrfBalGunPSR: Used to hold checkpointable state for the processes associated with ballistic g...
Definition: vrfBalGunPSR.h:36
virtual const char * type() const =0
Returns a string identifies the class type of component. Type values are defined in compTypes...
A locally simulated VRF object.
Definition: localObject.h:98
DtIntegerInputPort * myLosPort
Input Port Name: line-of-sight Input Port Description: Indicates the result of a line of sight calcul...
Definition: ballisticGun.h:426

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)