Esempio n. 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;
        }
Esempio n. 2
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);
        }
Esempio n. 3
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));
            }
        }