Example #1
0
 public void CopyFrom(EntityStatePDU other)
 {
     EntityId                         = other.EntityId;
     ForceId                          = other.ForceId;
     EntityType                       = other.EntityType;
     AlternativeEntityType            = other.AlternativeEntityType;
     LinearVelocity                   = other.LinearVelocity;
     Location                         = other.Location;
     Orientation                      = other.Orientation;
     Appearance.BitValue              = other.Appearance.BitValue;
     DeadRecokning.Algorithm          = other.DeadRecokning.Algorithm;
     DeadRecokning.LinearAcceleration = other.DeadRecokning.LinearAcceleration;
     MarkingText.CharacterSet         = other.MarkingText.CharacterSet;
     MarkingText.String               = other.MarkingText.String;
     Capabilities                     = other.Capabilities;
     if (ArticulatedParts.Length != other.ArticulatedParts.Length)
     {
         ArticulatedParts = new ArticulatedPart[other.ArticulatedParts.Length];
     }
     for (int i = 0; i < other.ArticulatedParts.Length; i++)
     {
         ArticulatedParts[i].TypeDesignator         = other.ArticulatedParts[i].TypeDesignator;
         ArticulatedParts[i].ChangeIndicator        = other.ArticulatedParts[i].ChangeIndicator;
         ArticulatedParts[i].TypeVariantAttached    = other.ArticulatedParts[i].TypeVariantAttached;
         ArticulatedParts[i].TypeVariantArticulated = other.ArticulatedParts[i].TypeVariantArticulated;
         ArticulatedParts[i].value = other.ArticulatedParts[i].value;
     }
 }
        public static void Calculate(EntityStatePDU entityState, float elapsedTime, out GeocentricCoord outLocation, out Vector3Float outOrientation)
        {
            switch (entityState.DeadRecokning.Algorithm)
            {
            case DeadReckoningAlgorithm.Other:
            case DeadReckoningAlgorithm.Static:
                outLocation    = (GeocentricCoord)entityState.Location;
                outOrientation = entityState.Orientation;
                return;

            case DeadReckoningAlgorithm.FPW:
                outLocation    = (GeocentricCoord)(entityState.Location + entityState.LinearVelocity * elapsedTime);
                outOrientation = entityState.Orientation;
                return;

            case DeadReckoningAlgorithm.RPW:
                outLocation    = (GeocentricCoord)(entityState.Location + entityState.LinearVelocity * elapsedTime);
                outOrientation = entityState.Orientation + entityState.DeadRecokning.AngularVelocity * elapsedTime;
                return;

            case DeadReckoningAlgorithm.RVW:
                outLocation    = (GeocentricCoord)(entityState.Location + (entityState.LinearVelocity * elapsedTime + entityState.DeadRecokning.LinearAcceleration * (0.5 * elapsedTime * elapsedTime)));
                outOrientation = entityState.Orientation + entityState.DeadRecokning.AngularVelocity * elapsedTime;
                return;

            case DeadReckoningAlgorithm.FVW:
                outLocation    = (GeocentricCoord)(entityState.Location + (entityState.LinearVelocity * elapsedTime + entityState.DeadRecokning.LinearAcceleration * (0.5 * elapsedTime * elapsedTime)));
                outOrientation = entityState.Orientation;
                return;
            }

            outLocation    = (GeocentricCoord)entityState.Location;
            outOrientation = entityState.Orientation;
        }
Example #3
0
        public void Tick()
        {
            if (ShouldSendNewPDU)
            {
                _disExerciseConnection.SendPDU(State);

                _lastSendTime = Time.time;
                if (_lastSentState == null)
                {
                    _lastSentState = new EntityStatePDU();
                }
                _lastSentState.CopyFrom(State);
            }
        }
Example #4
0
        private void ReceivedEntityStatePDU(EntityStatePDU entityState)
        {
            if (IsOwnEntity(entityState))
            {
                return;
            }

            DISReflectedEntity reflectedEntity;

            if (!_reflectedEntities.TryGetValue(entityState.EntityId, out reflectedEntity))
            {
                reflectedEntity = new DISReflectedEntity();
                _reflectedEntities[entityState.EntityId] = reflectedEntity;

                reflectedEntity.UpdateState(entityState);
                DISEntityJoined?.Invoke(reflectedEntity);
            }
            else
            {
                reflectedEntity.UpdateState(entityState);
                EntityUpdated?.Invoke(reflectedEntity);
            }
        }
Example #5
0
 private bool IsOwnEntity(EntityStatePDU entityState)
 {
     return(_publishedEntitiesIds.Contains(entityState.EntityId));
 }
Example #6
0
 public void UpdateState(EntityStatePDU newState)
 {
     State           = newState;
     _lastUpdateTime = Time.time;
 }