Exemple #1
0
        public void SetValues(ObjectFragment source)
        {
            DeckObject target = this;

            target.ObjectId               = source.ObjectId;
            target.ObjectIndex            = source.ObjectIndex;
            target.TypeId                 = source.TypeId;
            target.ObjectName             = source.ObjectName;
            target.TypeName               = source.TypeName;
            target.OwnerId                = source.OwnerId;
            target.InterpolatedLocation.X = source.Location.X; target.InterpolatedLocation.Y = source.Location.Y; target.InterpolatedLocation.Z = source.Location.Z;
            target.Velocity.X             = source.Velocity.X; target.Velocity.Y = source.Velocity.Y; target.Velocity.Z = source.Velocity.Z;
            target.Acceleration.X         = source.Acceleration.X; target.Acceleration.Y = source.Acceleration.Y; target.Acceleration.Z = source.Acceleration.Z;
            target.Orientation.X          = source.Orientation.X; target.Orientation.Y = source.Orientation.Y; target.Orientation.Z = source.Orientation.Z; target.Orientation.W = source.Orientation.W;
            target.AngularVelocity.X      = source.AngularVelocity.X; target.AngularVelocity.Y = source.AngularVelocity.Y; target.AngularVelocity.Z = source.AngularVelocity.Z; target.AngularVelocity.W = source.AngularVelocity.W;
            target.AngularAcceleration.X  = source.AngularAcceleration.X; target.AngularAcceleration.Y = source.AngularAcceleration.Y; target.AngularAcceleration.Z = source.AngularAcceleration.Z; target.AngularAcceleration.W = source.AngularAcceleration.W;
            target.BoundingSphereRadius   = source.BoundingSphereRadius;
            target.Mass = source.Mass;
            target.StatePayloadDialect = source.ExtensionDialect;
            target.StatePayloadLength  = source.ExtensionLength;
            target.StatePayloadData    = source.GetExtensionData();

            this.SmoothedLocation.X = source.Location.X;
            this.SmoothedLocation.Y = source.Location.Y;
            this.SmoothedLocation.Z = source.Location.Z;

            lastUpdateTime = DateTime.Now;
        }
Exemple #2
0
 public override byte FrameDataSize(int frameIndex)
 {
     if (frameIndex == 0)
     {
         return((byte)(DataPrefixSize + ObjectFragment.FragmentDataSize(frameIndex)));
     }
     else
     {
         return(ObjectFragment.FragmentDataSize(frameIndex));
     }
 }
Exemple #3
0
        public Guid TargetBubbleId = Guid.Empty; // 16

        public void SetExtension <ExtensionFragment>(ExtensionFragment extensionFragment)
        {
            using (MemoryStream bufferStream = new MemoryStream(0))
            {
                Serializer.Serialize(bufferStream, extensionFragment);
                byte[] bufferBytes = new byte[bufferStream.Length];
                Array.Copy(bufferStream.GetBuffer(), bufferBytes, bufferStream.Length);
                ObjectFragment.SetExtensionData(bufferBytes);
                ObjectFragment.ExtensionDialect = "GPB";
            }
        }
Exemple #4
0
 public ExtensionFragment GetExtension <ExtensionFragment>()
 {
     if (ObjectFragment.ExtensionDialect != "GPB")
     {
         throw new Exception("State dialect not Google Protocol Buffers (GPB): " + ObjectFragment.ExtensionDialect);
     }
     using (MemoryStream memoryStream = new MemoryStream(ObjectFragment.GetExtensionData(), 0, (int)ObjectFragment.ExtensionLength))
     {
         ExtensionFragment extensionFragment = Serializer.Deserialize <ExtensionFragment>(memoryStream);
         return(extensionFragment);
     }
 }
Exemple #5
0
        private IDataObject ToDataObject(ObjectFragment message)
        {
            var dataObject = new DataObject
            {
                Data     = message.Data,
                Resource = new Resource
                {
                    Uri = EtpUri.RootUri
                }
            };

            if (GzipEncoding.EqualsIgnoreCase(message.ContentEncoding))
            {
                dataObject.ContentEncoding = GzipEncoding;
            }

            return(dataObject);
        }
Exemple #6
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Evidences);

            string Token    = Intent.GetStringExtra("Token");
            string FullName = Intent.GetStringExtra("FullName");

            var TextViewFullName = FindViewById <TextView>(Resource.Id.textViewFullName);

            TextViewFullName.Text = FullName;

            ObjectFragment Data = (ObjectFragment)this.FragmentManager.FindFragmentByTag("Data");

            if (Data == null)
            {
                Data = new ObjectFragment();
                var FragmentTransaction = this.FragmentManager.BeginTransaction();
                FragmentTransaction.Add(Data, "Data");
                FragmentTransaction.Commit();

                var Client = new ServiceClient();
                Data.Evidences = await Client.GetEvidencesAsync(Token);
            }

            var ListViewEvidences = FindViewById <ListView>(Resource.Id.listViewEvidences);

            ListViewEvidences.Adapter = new EvidencesAdapter(this, Data.Evidences, Resource.Layout.EvidenceItem, Resource.Id.textViewTitle, Resource.Id.textViewStatus);

            ListViewEvidences.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                var Evidence = Data.Evidences[e.Position];

                var Intent = new Android.Content.Intent(this, typeof(EvidenceDetailsActivity));
                Intent.PutExtra("Token", Token);
                Intent.PutExtra("FullName", FullName);
                Intent.PutExtra("EvidenceID", Evidence.EvidenceID);
                Intent.PutExtra("Title", Evidence.Title);
                Intent.PutExtra("Status", Evidence.Status);
                StartActivity(Intent);
            };
        }
Exemple #7
0
        public void GetValues(ObjectFragment target)
        {
            DeckObject source = this;

            target.ObjectId              = source.ObjectId;
            target.ObjectIndex           = source.ObjectIndex;
            target.TypeId                = source.TypeId;
            target.ObjectName            = source.ObjectName;
            target.TypeName              = source.TypeName;
            target.OwnerId               = source.OwnerId;
            target.Location.X            = source.InterpolatedLocation.X; target.Location.Y = source.InterpolatedLocation.Y; target.Location.Z = source.InterpolatedLocation.Z;
            target.Velocity.X            = source.Velocity.X; target.Velocity.Y = source.Velocity.Y; target.Velocity.Z = source.Velocity.Z;
            target.Acceleration.X        = source.Acceleration.X; target.Acceleration.Y = source.Acceleration.Y; target.Acceleration.Z = source.Acceleration.Z;
            target.Orientation.X         = source.Orientation.X; target.Orientation.Y = source.Orientation.Y; target.Orientation.Z = source.Orientation.Z; target.Orientation.W = source.Orientation.W;
            target.AngularVelocity.X     = source.AngularVelocity.X; target.AngularVelocity.Y = source.AngularVelocity.Y; target.AngularVelocity.Z = source.AngularVelocity.Z; target.AngularVelocity.W = source.AngularVelocity.W;
            target.AngularAcceleration.X = source.AngularAcceleration.X; target.AngularAcceleration.Y = source.AngularAcceleration.Y; target.AngularAcceleration.Z = source.AngularAcceleration.Z; target.AngularAcceleration.W = source.AngularAcceleration.W;
            target.BoundingSphereRadius  = source.BoundingSphereRadius;
            target.Mass             = source.Mass;
            target.ExtensionDialect = source.StatePayloadDialect;
            target.SetExtensionData(source.StatePayloadData);
        }
Exemple #8
0
        public void SetValues(ObjectFragment source)
        {
            TankObject target = this;

            target.ObjectId = source.ObjectId;
            //target.ObjectIndex = source.ObjectIndex;
            target.TypeId     = source.TypeId;
            target.ObjectName = source.ObjectName;
            target.TypeName   = source.TypeName;
            //target.OwnerId = source.OwnerId;
            target.Location[0]            = source.Location.X; target.Location[1] = source.Location.Y; target.Location[2] = source.Location.Z;
            target.Velocity[0]            = source.Velocity.X; target.Velocity[1] = source.Velocity.Y; target.Velocity[2] = source.Velocity.Z;
            target.Acceleration[0]        = source.Acceleration.X; target.Acceleration[1] = source.Acceleration.Y; target.Acceleration[2] = source.Acceleration.Z;
            target.Orientation[0]         = source.Orientation.X; target.Orientation[1] = source.Orientation.Y; target.Orientation[2] = source.Orientation.Z; target.Orientation[3] = source.Orientation.W;
            target.AngularVelocity[0]     = source.AngularVelocity.X; target.AngularVelocity[1] = source.AngularVelocity.Y; target.AngularVelocity[2] = source.AngularVelocity.Z; target.AngularVelocity[3] = source.AngularVelocity.W;
            target.AngularAcceleration[0] = source.AngularAcceleration.X; target.AngularAcceleration[1] = source.AngularAcceleration.Y; target.AngularAcceleration[2] = source.AngularAcceleration.Z; target.AngularAcceleration[3] = source.AngularAcceleration.W;
            target.BoundingSphereRadius   = source.BoundingSphereRadius;
            target.Mass = source.Mass;
            target.StatePayloadDialect = source.ExtensionDialect;
            target.StatePayloadLength  = source.ExtensionLength;
            target.StatePayloadData    = source.GetExtensionData();
        }
Exemple #9
0
 public void FromObjectFragment(Guid bubbleId, ObjectFragment objectFragment)
 {
     this.BubbleId         = bubbleId;
     RemoteObjectIndex     = objectFragment.ObjectIndex;
     ObjectId              = objectFragment.ObjectId;
     ObjectName            = objectFragment.ObjectName;
     ParentObjectId        = objectFragment.ParentObjectId;
     TypeId                = objectFragment.TypeId;
     TypeName              = objectFragment.TypeName;
     OwnerId               = objectFragment.OwnerId;
     Location.X            = objectFragment.Location.X;
     Location.Y            = objectFragment.Location.Y;
     Location.Z            = objectFragment.Location.Z;
     Velocity.X            = objectFragment.Velocity.X;
     Velocity.Y            = objectFragment.Velocity.Y;
     Velocity.Z            = objectFragment.Velocity.Z;
     Acceleration.X        = objectFragment.Acceleration.X;
     Acceleration.Y        = objectFragment.Acceleration.Y;
     Acceleration.Z        = objectFragment.Acceleration.Z;
     Orientation.X         = objectFragment.Orientation.X;
     Orientation.Y         = objectFragment.Orientation.Y;
     Orientation.Z         = objectFragment.Orientation.Z;
     Orientation.W         = objectFragment.Orientation.W;
     AngularVelocity.X     = objectFragment.AngularVelocity.X;
     AngularVelocity.Y     = objectFragment.AngularVelocity.Y;
     AngularVelocity.Z     = objectFragment.AngularVelocity.Z;
     AngularVelocity.W     = objectFragment.AngularVelocity.W;
     AngularAcceleration.X = objectFragment.AngularAcceleration.X;
     AngularAcceleration.Y = objectFragment.AngularAcceleration.Y;
     AngularAcceleration.Z = objectFragment.AngularAcceleration.Z;
     AngularAcceleration.W = objectFragment.AngularAcceleration.W;
     BoundingSphereRadius  = objectFragment.BoundingSphereRadius;
     Mass                         = objectFragment.Mass;
     ExtensionDialect             = objectFragment.ExtensionDialect;
     ExtensionDialectMajorVersion = objectFragment.ExtensionDialectMajorVersion;
     ExtensionDialectMinorVersion = objectFragment.ExtensionDialectMinorVersion;
     ExtensionData                = new byte[objectFragment.ExtensionLength];
     Array.Copy(objectFragment.GetExtensionData(), ExtensionData, objectFragment.ExtensionLength);
 }
Exemple #10
0
 public void ToObjectFragment(ObjectFragment objectFragment)
 {
     objectFragment.ObjectId              = ObjectId;
     objectFragment.ObjectIndex           = LocalObjectIndex; // Remote bubbles have different index.
     objectFragment.ObjectName            = ObjectName;
     objectFragment.ParentObjectId        = ParentObjectId;
     objectFragment.TypeId                = TypeId;
     objectFragment.TypeName              = TypeName;
     objectFragment.OwnerId               = OwnerId;
     objectFragment.Location.X            = Location.X;
     objectFragment.Location.Y            = Location.Y;
     objectFragment.Location.Z            = Location.Z;
     objectFragment.Velocity.X            = Velocity.X;
     objectFragment.Velocity.Y            = Velocity.Y;
     objectFragment.Velocity.Z            = Velocity.Z;
     objectFragment.Acceleration.X        = Acceleration.X;
     objectFragment.Acceleration.Y        = Acceleration.Y;
     objectFragment.Acceleration.Z        = Acceleration.Z;
     objectFragment.Orientation.X         = Orientation.X;
     objectFragment.Orientation.Y         = Orientation.Y;
     objectFragment.Orientation.Z         = Orientation.Z;
     objectFragment.Orientation.W         = Orientation.W;
     objectFragment.AngularVelocity.X     = AngularVelocity.X;
     objectFragment.AngularVelocity.Y     = AngularVelocity.Y;
     objectFragment.AngularVelocity.Z     = AngularVelocity.Z;
     objectFragment.AngularVelocity.W     = AngularVelocity.W;
     objectFragment.AngularAcceleration.X = AngularAcceleration.X;
     objectFragment.AngularAcceleration.Y = AngularAcceleration.Y;
     objectFragment.AngularAcceleration.Z = AngularAcceleration.Z;
     objectFragment.AngularAcceleration.W = AngularAcceleration.W;
     objectFragment.BoundingSphereRadius  = BoundingSphereRadius;
     objectFragment.Mass                         = Mass;
     objectFragment.ExtensionDialect             = ExtensionDialect;
     objectFragment.ExtensionDialectMajorVersion = ExtensionDialectMajorVersion;
     objectFragment.ExtensionDialectMinorVersion = ExtensionDialectMinorVersion;
     byte[] buffer = new byte[ExtensionData.Length];
     Array.Copy(ExtensionData, buffer, ExtensionData.Length);
     objectFragment.SetExtensionData(buffer);
 }
Exemple #11
0
        public void OnInjectRequest(RemoteParticipant participant, InjectRequestMessage injectRequest)
        {
            InjectResponseMessage injectResponse = new InjectResponseMessage();
            injectResponse.MessageId = injectRequest.MessageId;

            ObjectFragment fragment=injectRequest.ObjectFragment;

            if (IdObjectDictionary.ContainsKey(fragment.ObjectId))
            {
                // Object exists already so this is modify
                TankObject obj = IdObjectDictionary[fragment.ObjectId];
                if (obj.OwnerId == participant.ParticipantId)
                {
                    obj.SetValues(fragment);
                    ObjectMoved(obj);
                    injectResponse.FailureCode = MxpResponseCodes.SUCCESS;
                    participant.Session.Send(injectResponse);
                }
                else
                {
                    injectResponse.FailureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION;
                    participant.Session.Send(injectResponse);
                }
            }
            else
            {
                // Object does not exist so this is inject
                TankObject obj = new TankObject();
                obj.OwnerId = participant.ParticipantId;
                obj.SetValues(fragment);
                AddObject(obj);
                ObjectInjected(obj);
                injectResponse.FailureCode = MxpResponseCodes.SUCCESS;
                participant.Session.Send(injectResponse);
            }


        }
Exemple #12
0
        public void OnMessage(Message message)
        {
            if (message.GetType() == typeof(JoinResponseMessage))
            {
                JoinResponseMessage joinResponse = (JoinResponseMessage)message;
                if (joinResponse.FailureCode == MxpResponseCodes.SUCCESS)
                {
                    Bubble.BubbleName                   = joinResponse.BubbleName;
                    Bubble.CloudUrl                     = joinResponse.BubbleAssetCacheUrl;
                    Bubble.ServerProgramName            = joinResponse.ProgramName;
                    Bubble.ServerProgramMajorVersion    = joinResponse.ProgramMajorVersion;
                    Bubble.ServerProgramMinorVersion    = joinResponse.ProgramMinorVersion;
                    Bubble.ServerProtocolMajorVersion   = joinResponse.ProtocolMajorVersion;
                    Bubble.ServerProtocolMinorVersion   = joinResponse.ProtocolMinorVersion;
                    Bubble.ServerProtocolSourceRevision = (int)joinResponse.ProtocolSourceRevision;
                    Bubble.BubbleRange                  = 100;
                }
            }

            if (message.GetType() == typeof(PerceptionEventMessage))
            {
                PerceptionEventMessage perception = (PerceptionEventMessage)message;
                ObjectFragment         fragment   = perception.ObjectFragment;

                DeckObject obj = null;
                if (!Bubble.Objects.ContainsKey(fragment.ObjectIndex))
                {
                    obj = new DeckObject();
                    Bubble.Objects.Add(fragment.ObjectIndex, obj);
                    Bubble.IdObjectDictionary.Add(fragment.ObjectId, obj);
                }
                else
                {
                    obj = Bubble.Objects[fragment.ObjectIndex];
                }

                obj.SetValues(fragment);

                if (perception.ObjectFragment.ObjectId == deck.AvatarId)
                {
                    deck.ReceivedAvatarObject = obj;
                }
            }

            if (message.GetType() == typeof(MovementEventMessage))
            {
                MovementEventMessage movement = (MovementEventMessage)message;

                DeckObject obj = null;
                if (Bubble.Objects.ContainsKey(movement.ObjectIndex))
                {
                    obj = Bubble.Objects[movement.ObjectIndex];
                    obj.SetValues(movement);
                }
            }

            if (message.GetType() == typeof(DisappearanceEventMessage))
            {
                DisappearanceEventMessage disappearance = (DisappearanceEventMessage)message;
                if (Bubble.Objects.ContainsKey(disappearance.ObjectIndex))
                {
                    if (Bubble.Objects.ContainsKey(disappearance.ObjectIndex))
                    {
                        DeckObject obj = Bubble.Objects[disappearance.ObjectIndex];
                        Bubble.IdObjectDictionary.Remove(obj.ObjectId);
                        Bubble.Objects.Remove(disappearance.ObjectIndex);
                    }
                }
            }

            if (message.GetType() == typeof(ActionEventMessage))
            {
                ActionEventMessage actionEvent            = (ActionEventMessage)message;
                String             sourceObjectIdentifier = null;
                if (Bubble.IdObjectDictionary.ContainsKey(actionEvent.ActionFragment.SourceObjectId))
                {
                    DeckObject obj = Bubble.IdObjectDictionary[actionEvent.ActionFragment.SourceObjectId];
                    sourceObjectIdentifier = obj.ObjectName;
                }
                else
                {
                    sourceObjectIdentifier = actionEvent.ActionFragment.SourceObjectId.ToString();
                }
                deck.ConsoleLines.Add(sourceObjectIdentifier + " " + actionEvent.ActionFragment.ActionName + " (" + actionEvent.ActionFragment.ExtensionDialect + "): " + Encoding.UTF8.GetString(actionEvent.ActionFragment.GetExtensionData(), 0, (int)actionEvent.ActionFragment.ExtensionLength));
            }
        }