-
Notifications
You must be signed in to change notification settings - Fork 5
DISSendComponent
The DISSendComponent handles basic sending DIS functionality.
It should be attached to actors where sending DIS is desired.
By default the DISSendComponent offers automatic Entity State PDU sending
for the associated DIS Entity. Maintains a list of appropriate
DIS variables (such as Entity ID).
public class DISSendComponent
: MonoBehaviour
Access | Type | Name | Description | |
---|---|---|---|---|
Public | EntityIDEditor | CurrentEntityID | The Entity ID of the associated entity | |
Public | EntityTypeEditor | CurrentEntityType | The Entity Type of the associated entity. Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity. | |
Public | EDeadReckoningAlgorithm | DeadReckoningAlgorithm | The dead reckoning algorithm to use | |
Public | float | DeadReckoningOrientationThresholdDegrees | If the dead reckoning orientation deviates more than this value away from the actual orientation, a new Entity State PDU will be sent | |
Public | float | DeadReckoningPositionThresholdMeters | If the dead reckoning position deviates more than this value away from the actual position in any axis, a new Entity State PDU will be sent | |
Private | float | DeltaTimeSinceLastPDU | The time in seconds since the last PDU was recieved for this entity | |
Public | GameObject | DISGameManager | A reference to the DIS game manager game object | |
Private | DISGameManager | disGameManagerScript | A reference to the DISGameManager script | |
Public | float | DISHeartbeatSeconds | How often an Entity State PDU should be sent out for this entity | |
Public | int | EntityAppearance | Specifies the dynamic changes to the entities appearance attributes | |
Public | int | EntityCapabilities | The DIS Capabilities that the entity should have | |
Public | EForceID | EntityForceID | Specifies the team or side the DIS entity is on | |
Public | string | EntityMarking | Designates a friendly name for the DIS entity | |
Public | float | EntityStateCalculationRate | The rate at which the timer that calculates the current linear velocity, linear acceleration, and angular acceleration of the entity gets executed | |
Public | EEntityStateSendingMode | EntityStatePDUSendingMode | Dictates if none are sent, Entity State PDUs are sent, or Entity State Update PDUs are sent | |
Private | GeoreferenceSystem | georeferenceScript | A reference to the GeoreferenceSystem script. | |
Private | Vector3 | LastCalculatedAngularVelocity | The angluar velocity at the last calculation step | |
Private | Vector3 | LastCalculatedBodyLinearAcceleration | The body linear acceleration at the last calculation step | |
Private | Vector3 | LastCalculatedBodyLinearVelocity | The body linear velocity at the last calculation step | |
Private | Vector3 | LastCalculatedECEFLinearAcceleration | The ECEF linear acceleration at the last calculation step | |
Private | Vector3 | LastCalculatedECEFLinearVelocity | The ECEF linear velocity at the last calculation step | |
Private | Vector3 | LastCalculatedUnityLinearVelocity | The Unity linear velocity at the last calculation step | |
Private | Vector3 | LastCalculatedUnityLocation | The Unity location at the last calculation step | |
Private | Quaternion | LastCalculatedUnityRotation | The Unity rotation at the last calculation step | |
Public | EntityStatePdu | MostRecentDeadReckoningPDU | The most recent Dead Reckoned Entity State PDU that has been calculated | |
Public | EntityStatePdu | MostRecentEntityStatePDU | The most recent Entity State PDU that has been received | |
Private | PDUSender | pduSenderScript | A reference to the PDUSender script. | |
Private | float | TimeOfLastParametersCalculation | The time at which the last parameter was calculated in seconds since game start |
Access | Return | Name | Description | |
---|---|---|---|---|
Public | Vector3 | CalculateAngularVelocity() | Calculates the Angular Velocity of the entity that this component is attached to | |
Public | void | CalculateBodyLinearVelocityAndAcceleration(Vector3 AngularVelocity, out Vector3 BodyLinearVelocity, out Vector3 BodyLinearAcceleration) | Calculates the Linear Velocity and Linear Acceleration of the entity that this component is attached to | |
Public | void | CalculateECEFLinearVelocityAndAcceleration(out Vector3 ECEFLinearVelocity, out Vector3 ECEFLinearAcceleration) | Calculates the Linear Velocity and Linear Acceleration of the entity that this component is attached to | |
Public | bool | CheckDeadReckoningThreshold() | Compares the current Dead Reckoning location/orientation to the actual location/orientation of the entity | |
Public | bool | CheckOrientationMatrixThreshold() | Checks whether or not the orientation threshold between the actual orientation and Dead Reckoning orientation has been exceeded | |
Public | bool | CheckOrientationQuaternionThreshold() | Checks whether or not the orientation threshold between the actual orientation and Dead Reckoning orientation has been exceeded | |
Protected | bool | EmitAppropriatePDU(EntityStatePdu pduToSend) | Takes in an Entity State PDU and emits it as an Entity State or Entity State Update PDU | |
Public | EntityStatePdu | FormEntityStatePDU() | Forms an Entity State PDU based on current known information about the Entity | |
Private | void | OnDestroy() | This function is called when the MonoBehaviour will be destroyed. | |
Public | bool | SendEntityStatePDU() | Attempts to send an updated Entity State or Entity State Update PDU | |
Public | void | SetDeadReckoningAlgorithm(EDeadReckoningAlgorithm NewDeadReckoningAlgorithm) | Updates the Dead Reckoning algorithm being used by the Send Component | |
Public | void | SetEntityAppearance(int NewEntityAppearance) | Updates the appearance of the entity | |
Public | void | SetEntityCapabilities(int NewEntityCapabilities) | Updates the Capabilities that the entity has | |
Private | void | Start() | Start is called on the frame when a script is enabled just before any of the Update methods are called the first time. | |
Private | void | Update() | Update is called every frame, if the MonoBehaviour is enabled. | |
Protected | void | UpdateEntityStateCalculations() | Updates last calculated linear velocity, linear acceleration, and angular velocity |
public FEntityID EntityID
The Entity ID of the associated entity. Each Entity ID should be unique to an entity in the sim.
public EntityIDEditor EntityType
The Entity Type of the associated entity. Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity.
public EDeadReckoningAlgorithm DeadReckoningAlgorithm = EDeadReckoningAlgorithm.Static
The dead reckoning algorithm to use.
public float DeadReckoningOrientationThresholdDegrees = 3
The orientation threshold to use for dead reckoning. If the dead reckoning orientation deviates more than this value away from the actual orientation, a new Entity State PDU will be sent.
This value should be in degrees.
Minimum Value: 0
public float DeadReckoningPositionThresholdMeters = 1
The position threshold to use for dead reckoning. If the dead reckoning position deviates more than this value away from the actual position in any axis, a new Entity State PDU will be sent.
This value should be in meters.
Minimum Value: 0
private float DeltaTimeSinceLastPDU = 0
The time in seconds since the last PDU was recieved for this entity.
public GameObject DISGameManager
A reference to the DIS game manager.
private Coroutine DISHeartbeatCoroutine
A reference to the DISGameManager script
public float DISHeartbeatSeconds = 5.0f
How often an Entity State PDU should be sent out for this entity.
Timer gets reset if an Entity State PDU gets sent out by this component by another means (ex: threshold clipping).
Minimum Value: 0
public int EntityAppearance = 0
Specifies the dynamic changes to the entities appearance attributes.
Minimum Value: 0
public int EntityCapabilities = 0
The DIS Capabilities that the entity should have. Int representation of a collection of boolean fields which describe the capabilities of the entity.
Minimum Value: 0
public EForceID EntityForceID
The Force ID of the associated entity. Specifies the team or side the DIS entity is on.
public string EntityMarking
The Entity Marking of the associated entity. Designates a friendly name for the DIS entity.
Max of 11 characters should be used. If more than 11 are used, it will be truncated.
public float EntityStateCalculationRate = 0.1f
The rate at which the timer that calculates the current linear velocity, linear acceleration, and angular acceleration of the entity gets executed.
The values calculated by this timer get utilized when forming an Entity State PDU.
Minimum Value: 0.01
public EEntityStateSendingMode EntityStatePDUSendingMode = EEntityStateSendingMode.None
The sending mode that this entity should use for Entity State PDUs.
Dictates if none are sent, Entity State PDUs are sent, or Entity State Update PDUs are sent.
Distribution of Entity State PDUs are handled internally by the DIS Component via the overridable "SendEntityStatePDU" function.
public GeoreferenceSystem georeferenceScript
A reference to the GeoreferenceSystem script.
private Vector3 LastCalculatedAngularVelocity
The angluar velocity at the last calculation step.
private Vector3 LastCalculatedBodyLinearAcceleration
The body linear acceleration at the last calculation step.
private Vector3 LastCalculatedBodyLinearVelocity
The body linear velocity at the last calculation step.
private Vector3 LastCalculatedECEFLinearAcceleration
The ECEF linear acceleration at the last calculation step.
private Vector3 LastCalculatedECEFLinearVelocity
The ECEF linear velocity at the last calculation step.
private Vector3 LastCalculatedUnityLinearVelocity
The Unity linear velocity at the last calculation step.
private Vector3 LastCalculatedUnityLocation
The Unity location at the last calculation step.
private FRotator LastCalculatedUnityRotation
The Unity rotation at the last calculation step.
public EntityStatePdu MostRecentDeadReckoningPDU
The most recent Dead Reckoned Entity State PDU that has been calculated.
public EntityStatePdu MostRecentEntityStatePDU
The most recent Entity State PDU that has been received.
A reference to the PDUSender script.
private float TimeOfLastParametersCalculation
The time at which the last parameter was calculated in seconds since game start.
public Vector3 CalculateAngularVelocity()
Calculates the Angular Velocity of the entity that this component is attached to.
Returns an Vector3 containing the angular velocity in radians per second.
public void CalculateBodyLinearVelocityAndAcceleration
(
Vector3 AngularVelocity,
out Vector3 BodyLinearVelocity,
out Vector3 BodyLinearAcceleration
)
Calculates the Linear Velocity and Linear Acceleration of the entity that this component is attached to. Calculates them in terms of entity body coordinates.
Parameter | Description |
---|---|
AngularVelocity | The current angular velocity of the entity |
BodyLinearVelocity | The linear velocity of the entity in Body coordinates |
BodyLinearAcceleration | The linear acceleration of the entity in Body coordinates |
public void CalculateECEFLinearVelocityAndAcceleration
(
out Vector3 ECEFLinearVelocity,
out Vector3 ECEFLinearAcceleration
)
Calculates the Linear Velocity and Linear Acceleration of the entity that this component is attached to. Calculates them in terms of ECEF coordinates.
Parameter | Description |
---|---|
ECEFLinearVelocity | The linear velocity of the entity in ECEF coordinates |
ECEFLinearAcceleration | The linear acceleration of the entity in ECEF coordinates |
public bool CheckDeadReckoningThreshold()
Compares the current Dead Reckoning location/orientation to the actual location/orientation of the entity.
Returns |
---|
True if the comparison is outside of the Dead Reckoning threshold |
public bool CheckOrientationMatrixThreshold()
Checks whether or not the orientation threshold between the actual orientation and Dead Reckoning orientation has been exceeded. Utilizes matrices to calculate it.
Returns |
---|
True if the comparison is outside of the orientation threshold |
public bool CheckOrientationQuaternionThreshold()
Checks whether or not the orientation threshold between the actual orientation and Dead Reckoning orientation has been exceeded. Utilizes quaternions to calculate it.
Returns |
---|
True if the comparison is outside of the orientation threshold |
bool EmitAppropriatePDU
(
EntityStatePdu pduToSend
)
Takes in an Entity State PDU and emits it as an Entity State or Entity State Update PDU. Decides based on what EntityStatePDUSendingMode is set to.
Parameter | Description |
---|---|
pduToSend | The Entity State PDU to emit |
Returns |
---|
True if packets were sent correctly |
public EntityStatePdu FormEntityStatePDU()
Forms an Entity State PDU based on current known information about the Entity.
Returns |
---|
The Entity State PDU that was formed |
private void OnDestroy()
This function is called when the MonoBehaviour will be destroyed.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDestroy.html
public bool SendEntityStatePDU()
Attempts to send an updated Entity State or Entity State Update PDU. Checks Dead Reckoning threshold prior to sending.
Returns |
---|
True if an entity state PDU or entity state update PDU was sent |
public void SetDeadReckoningAlgorithm
(
EDeadReckoningAlgorithm NewDeadReckoningAlgorithm
)
Updates the Dead Reckoning algorithm being used by the Send Component.
Parameter | Description |
---|---|
NewDeadReckoningAlgorithm | The new dead reckoning algorithm to use |
public void SetEntityAppearance
(
int NewEntityAppearance
)
Updates the appearance of the entity.
Parameter | Description |
---|---|
NewEntityAppearance | The new appearance that the entity has |
public void SetEntityCapabilities
(
int NewEntityCapabilities
)
Updates the Capabilities that the entity has.
Parameter | Description |
---|---|
NewEntityCapabilities | The new DIS capabilities that the entity has |
private void Start()
Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
void Update()
Update is called every frame, if the MonoBehaviour is enabled.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html
void UpdateEntityStateCalculations()
Updates last calculated linear velocity, linear acceleration, and angular velocity.