/// <summary> /// Create an OSDMap from the appearance data /// </summary> public OSDMap Pack(EntityTransferContext ctx) { OSDMap data = new OSDMap(); data["serial"] = OSD.FromInteger(m_serial); data["height"] = OSD.FromReal(m_avatarHeight); // Wearables // // This will send as many or as few wearables as we have, unless a count // is given. Used for legacy (pre 0.4) versions. int count = ctx.WearablesCount; if (ctx.WearablesCount == -1) count = m_wearables.Length; OSDArray wears = new OSDArray(count); for (int i = 0; i < count; i++) { AvatarWearable dummyWearable = new AvatarWearable(); if (i < m_wearables.Length) wears.Add(m_wearables[i].Pack()); else wears.Add(dummyWearable.Pack()); } data["wearables"] = wears; // Avatar Textures OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT); for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) { if (m_texture.FaceTextures[i] != null) textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID)); else textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); } data["textures"] = textures; if (m_cacheitems != null) { OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems); if (baked != null) data["bakedcache"] = baked; } // Visual Parameters OSDBinary visualparams = new OSDBinary(m_visualparams); data["visualparams"] = visualparams; lock (m_attachments) { // Attachments OSDArray attachs = new OSDArray(m_attachments.Count); foreach (AvatarAttachment attach in GetAttachments()) attachs.Add(attach.Pack()); data["attachments"] = attachs; } return data; }
public override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx) { base.Unpack(map, scene, ctx); }
public OSDMap Pack(EntityTransferContext ctx) { OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentPosition"); args["region_handle"] = OSD.FromString(RegionHandle.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["agent_uuid"] = OSD.FromUUID(AgentID); args["session_uuid"] = OSD.FromUUID(SessionID); args["position"] = OSD.FromString(Position.ToString()); args["velocity"] = OSD.FromString(Velocity.ToString()); args["center"] = OSD.FromString(Center.ToString()); args["size"] = OSD.FromString(Size.ToString()); args["at_axis"] = OSD.FromString(AtAxis.ToString()); args["left_axis"] = OSD.FromString(LeftAxis.ToString()); args["up_axis"] = OSD.FromString(UpAxis.ToString()); args["far"] = OSD.FromReal(Far); args["changed_grid"] = OSD.FromBoolean(ChangedGrid); if ((Throttles != null) && (Throttles.Length > 0)) args["throttles"] = OSD.FromBinary(Throttles); if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } args["children_seeds"] = childrenSeeds; } return args; }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) { //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); if (args.ContainsKey("region_id")) UUID.TryParse(args["region_id"].AsString(), out RegionID); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); if (args["agent_uuid"] != null) AgentID = args["agent_uuid"].AsUUID(); if (args["session_uuid"] != null) SessionID = args["session_uuid"].AsUUID(); if (args["position"] != null) Vector3.TryParse(args["position"].AsString(), out Position); if (args["velocity"] != null) Vector3.TryParse(args["velocity"].AsString(), out Velocity); if (args["center"] != null) Vector3.TryParse(args["center"].AsString(), out Center); if (args["size"] != null) Vector3.TryParse(args["size"].AsString(), out Size); if (args["at_axis"] != null) Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); if (args["up_axis"] != null) Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); if (args.ContainsKey("wait_for_root") && args["wait_for_root"] != null) SenderWantsToWaitForRoot = args["wait_for_root"].AsBoolean(); if (args["far"] != null) Far = (float)(args["far"].AsReal()); if (args["aspect"] != null) Aspect = (float)args["aspect"].AsReal(); if (args["throttles"] != null) Throttles = args["throttles"].AsBinary(); if (args["locomotion_state"] != null) UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); if (args["head_rotation"] != null) Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); if (args["body_rotation"] != null) Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); if (args["control_flags"] != null) UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); if (args["energy_level"] != null) EnergyLevel = (float)(args["energy_level"].AsReal()); if (args["god_level"] != null) Byte.TryParse(args["god_level"].AsString(), out GodLevel); if (args["always_run"] != null) AlwaysRun = args["always_run"].AsBoolean(); if (args["prey_agent"] != null) PreyAgent = args["prey_agent"].AsUUID(); if (args["agent_access"] != null) Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); if (args.ContainsKey("agent_cof") && args["agent_cof"] != null) agentCOF = args["agent_cof"].AsUUID(); if (args.ContainsKey("crossingflags") && args["crossingflags"] != null) CrossingFlags = (byte)args["crossingflags"].AsInteger(); if (args.ContainsKey("active_group_id") && args["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if (args.ContainsKey("active_group_name") && args["active_group_name"] != null) ActiveGroupName = args["active_group_name"].AsString(); if(args.ContainsKey("active_group_title") && args["active_group_title"] != null) ActiveGroupTitle = args["active_group_title"].AsString(); if (args.ContainsKey("groups") && (args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) { OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); ChildrenCapSeeds = new Dictionary<ulong, string>(); foreach (OSD o in childrenSeeds) { if (o.Type == OSDType.Map) { ulong handle = 0; string seed = ""; OSDMap pair = (OSDMap)o; if (pair["handle"] != null) if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) continue; if (pair["seed"] != null) seed = pair["seed"].AsString(); if (!ChildrenCapSeeds.ContainsKey(handle)) ChildrenCapSeeds.Add(handle, seed); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } if (args["default_animation"] != null) { try { DefaultAnim = new Animation((OSDMap)args["default_animation"]); } catch { DefaultAnim = null; } } if (args["animation_state"] != null) { try { AnimState = new Animation((OSDMap)args["animation_state"]); } catch { AnimState = null; } } MovementAnimationOverRides.Clear(); if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array) { OSDArray AOs = (OSDArray)(args["movementAO"]); int count = AOs.Count; for (int i = 0; i < count; i++) { OSDMap ao = (OSDMap)AOs[i]; if (ao["state"] != null && ao["uuid"] != null) { string state = ao["state"].AsString(); UUID id = ao["uuid"].AsUUID(); MovementAnimationOverRides[state] = id; } } } if (args.ContainsKey("motion_state")) MotionState = (byte)args["motion_state"].AsInteger(); //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} // packed_appearence should contain all appearance information if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance"); Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); } else { // if missing try the old pack method m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method"); Appearance = new AvatarAppearance(); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args["visual_params"] != null) Appearance.SetVisualParams(args["visual_params"].AsBinary()); if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove } /* moved above if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); else m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); */ if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) CallbackURI = args["callback_uri"].AsString(); // Attachment objects if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) { OSDArray attObjs = (OSDArray)(args["attach_objects"]); AttachmentObjects = new List<ISceneObject>(); AttachmentObjectStates = new List<string>(); foreach (OSD o in attObjs) { if (o.Type == OSDType.Map) { OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); AttachmentObjects.Add(so); AttachmentObjectStates.Add(info["state"].AsString()); } } } if (args["parent_part"] != null) ParentPart = args["parent_part"].AsUUID(); if (args["sit_offset"] != null) Vector3.TryParse(args["sit_offset"].AsString(), out SitOffset); }
public override OSDMap Pack(EntityTransferContext ctx) { return base.Pack(ctx); }
public virtual OSDMap Pack(EntityTransferContext ctx) { // m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); args["region_id"] = OSD.FromString(RegionID.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["agent_uuid"] = OSD.FromUUID(AgentID); args["session_uuid"] = OSD.FromUUID(SessionID); args["position"] = OSD.FromString(Position.ToString()); args["velocity"] = OSD.FromString(Velocity.ToString()); args["center"] = OSD.FromString(Center.ToString()); args["size"] = OSD.FromString(Size.ToString()); args["at_axis"] = OSD.FromString(AtAxis.ToString()); args["left_axis"] = OSD.FromString(LeftAxis.ToString()); args["up_axis"] = OSD.FromString(UpAxis.ToString()); //backwards compatibility args["changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["far"] = OSD.FromReal(Far); args["aspect"] = OSD.FromReal(Aspect); if ((Throttles != null) && (Throttles.Length > 0)) args["throttles"] = OSD.FromBinary(Throttles); args["locomotion_state"] = OSD.FromString(LocomotionState.ToString()); args["head_rotation"] = OSD.FromString(HeadRotation.ToString()); args["body_rotation"] = OSD.FromString(BodyRotation.ToString()); args["control_flags"] = OSD.FromString(ControlFlags.ToString()); args["energy_level"] = OSD.FromReal(EnergyLevel); args["god_level"] = OSD.FromString(GodLevel.ToString()); args["always_run"] = OSD.FromBoolean(AlwaysRun); args["prey_agent"] = OSD.FromUUID(PreyAgent); args["agent_access"] = OSD.FromString(AgentAccess.ToString()); args["agent_cof"] = OSD.FromUUID(agentCOF); args["crossingflags"] = OSD.FromInteger(CrossingFlags); args["active_group_id"] = OSD.FromUUID(ActiveGroupID); args["active_group_name"] = OSD.FromString(ActiveGroupName); if(ActiveGroupTitle != null) args["active_group_title"] = OSD.FromString(ActiveGroupTitle); if ((Groups != null) && (Groups.Length > 0)) { OSDArray groups = new OSDArray(Groups.Length); foreach (AgentGroupData agd in Groups) groups.Add(agd.PackUpdateMessage()); args["groups"] = groups; } if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } args["children_seeds"] = childrenSeeds; } if ((Anims != null) && (Anims.Length > 0)) { OSDArray anims = new OSDArray(Anims.Length); foreach (Animation aanim in Anims) anims.Add(aanim.PackUpdateMessage()); args["animations"] = anims; } if (DefaultAnim != null) { args["default_animation"] = DefaultAnim.PackUpdateMessage(); } if (AnimState != null) { args["animation_state"] = AnimState.PackUpdateMessage(); } if (MovementAnimationOverRides.Count > 0) { OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count); { foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides) { OSDMap ao = new OSDMap(2); ao["state"] = OSD.FromString(kvp.Key); ao["uuid"] = OSD.FromUUID(kvp.Value); AOs.Add(ao); } } args["movementAO"] = AOs; } if (MotionState != 0) { args["motion_state"] = OSD.FromInteger(MotionState); } if (Appearance != null) args["packed_appearance"] = Appearance.Pack(ctx); if ((Controllers != null) && (Controllers.Length > 0)) { OSDArray controls = new OSDArray(Controllers.Length); foreach (ControllerData ctl in Controllers) controls.Add(ctl.PackUpdateMessage()); args["controllers"] = controls; } if ((CallbackURI != null) && (!CallbackURI.Equals(""))) args["callback_uri"] = OSD.FromString(CallbackURI); // Attachment objects for fatpack messages if (AttachmentObjects != null) { int i = 0; OSDArray attObjs = new OSDArray(AttachmentObjects.Count); foreach (ISceneObject so in AttachmentObjects) { OSDMap info = new OSDMap(4); info["sog"] = OSD.FromString(so.ToXml2()); info["extra"] = OSD.FromString(so.ExtraToXmlString()); info["modified"] = OSD.FromBoolean(so.HasGroupChanged); try { info["state"] = OSD.FromString(AttachmentObjectStates[i++]); } catch (IndexOutOfRangeException) { m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list."); } attObjs.Add(info); } args["attach_objects"] = attObjs; } args["parent_part"] = OSD.FromUUID(ParentPart); args["sit_offset"] = OSD.FromString(SitOffset.ToString()); return args; }
public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) { if (args.ContainsKey("region_handle")) UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); if (args["agent_uuid"] != null) AgentID = args["agent_uuid"].AsUUID(); if (args["session_uuid"] != null) SessionID = args["session_uuid"].AsUUID(); if (args["position"] != null) Vector3.TryParse(args["position"].AsString(), out Position); if (args["velocity"] != null) Vector3.TryParse(args["velocity"].AsString(), out Velocity); if (args["center"] != null) Vector3.TryParse(args["center"].AsString(), out Center); if (args["size"] != null) Vector3.TryParse(args["size"].AsString(), out Size); if (args["at_axis"] != null) Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis); if (args["up_axis"] != null) Vector3.TryParse(args["up_axis"].AsString(), out UpAxis); if (args["changed_grid"] != null) ChangedGrid = args["changed_grid"].AsBoolean(); if (args["far"] != null) Far = (float)(args["far"].AsReal()); if (args["throttles"] != null) Throttles = args["throttles"].AsBinary(); if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) { OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); ChildrenCapSeeds = new Dictionary<ulong, string>(); foreach (OSD o in childrenSeeds) { if (o.Type == OSDType.Map) { ulong handle = 0; string seed = ""; OSDMap pair = (OSDMap)o; if (pair["handle"] != null) if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) continue; if (pair["seed"] != null) seed = pair["seed"].AsString(); if (!ChildrenCapSeeds.ContainsKey(handle)) ChildrenCapSeeds.Add(handle, seed); } } } }
/// <summary> /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json /// </summary> /// <returns>map of the agent circuit data</returns> public OSDMap PackAgentCircuitData(EntityTransferContext ctx) { OSDMap args = new OSDMap(); args["agent_id"] = OSD.FromUUID(AgentID); args["base_folder"] = OSD.FromUUID(BaseFolder); args["caps_path"] = OSD.FromString(CapsPath); if (ChildrenCapSeeds != null) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } if (ChildrenCapSeeds.Count > 0) args["children_seeds"] = childrenSeeds; } args["child"] = OSD.FromBoolean(child); args["circuit_code"] = OSD.FromString(circuitcode.ToString()); args["first_name"] = OSD.FromString(firstname); args["last_name"] = OSD.FromString(lastname); args["inventory_folder"] = OSD.FromUUID(InventoryFolder); args["secure_session_id"] = OSD.FromUUID(SecureSessionID); args["session_id"] = OSD.FromUUID(SessionID); args["service_session_id"] = OSD.FromString(ServiceSessionID); args["start_pos"] = OSD.FromString(startpos.ToString()); args["client_ip"] = OSD.FromString(IPAddress); args["viewer"] = OSD.FromString(Viewer); args["channel"] = OSD.FromString(Channel); args["mac"] = OSD.FromString(Mac); args["id0"] = OSD.FromString(Id0); if (Appearance != null) { args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); OSDMap appmap = Appearance.Pack(ctx); args["packed_appearance"] = appmap; } // Old, bad way. Keeping it fow now for backwards compatibility // OBSOLETE -- soon to be deleted if (ServiceURLs != null && ServiceURLs.Count > 0) { OSDArray urls = new OSDArray(ServiceURLs.Count * 2); foreach (KeyValuePair<string, object> kvp in ServiceURLs) { //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value); urls.Add(OSD.FromString(kvp.Key)); urls.Add(OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString())); } args["service_urls"] = urls; } // again, this time the right way if (ServiceURLs != null && ServiceURLs.Count > 0) { OSDMap urls = new OSDMap(); foreach (KeyValuePair<string, object> kvp in ServiceURLs) { //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value); urls[kvp.Key] = OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString()); } args["serviceurls"] = urls; } return args; }
public void AgentPositionTest01() { UUID AgentId1 = UUID.Random(); UUID SessionId1 = UUID.Random(); uint CircuitCode1 = uint.MinValue; Vector3 Size1 = Vector3.UnitZ; Vector3 Position1 = Vector3.UnitX; Vector3 LeftAxis1 = Vector3.UnitY; Vector3 UpAxis1 = Vector3.UnitZ; Vector3 AtAxis1 = Vector3.UnitX; ulong RegionHandle1 = ulong.MinValue; byte[] Throttles1 = new byte[] {0, 1, 0}; Vector3 Velocity1 = Vector3.Zero; float Far1 = 256; bool ChangedGrid1 = false; Vector3 Center1 = Vector3.Zero; AgentPosition position1 = new AgentPosition(); position1.AgentID = AgentId1; position1.SessionID = SessionId1; position1.CircuitCode = CircuitCode1; position1.Size = Size1; position1.Position = Position1; position1.LeftAxis = LeftAxis1; position1.UpAxis = UpAxis1; position1.AtAxis = AtAxis1; position1.RegionHandle = RegionHandle1; position1.Throttles = Throttles1; position1.Velocity = Velocity1; position1.Far = Far1; position1.ChangedGrid = ChangedGrid1; position1.Center = Center1; ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); cadu.AgentID = AgentId1.Guid; cadu.ActiveGroupID = UUID.Zero.Guid; cadu.throttles = Throttles1; cadu.drawdistance = Far1; cadu.Position = Position1; cadu.Velocity = Velocity1; cadu.regionHandle = RegionHandle1; cadu.cameraPosition = Center1; cadu.AVHeight = Size1.Z; AgentPosition position2 = new AgentPosition(); position2.CopyFrom(cadu, position1.SessionID); Assert.IsTrue( position2.AgentID == position1.AgentID && position2.Size == position1.Size && position2.Position == position1.Position && position2.Velocity == position1.Velocity && position2.Center == position1.Center && position2.RegionHandle == position1.RegionHandle && position2.Far == position1.Far ,"Copy From ChildAgentDataUpdate failed"); position2 = new AgentPosition(); Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); EntityTransferContext ctx = new EntityTransferContext(); position2.Unpack(position1.Pack(ctx), null, ctx); Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed"); Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed"); Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed"); Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed"); Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed"); Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed"); Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed"); Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed"); Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed"); Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); }
public virtual OSDMap Pack(EntityTransferContext ctx) { int wearablesCount = -1; // m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); args["region_id"] = OSD.FromString(RegionID.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["agent_uuid"] = OSD.FromUUID(AgentID); args["session_uuid"] = OSD.FromUUID(SessionID); args["position"] = OSD.FromString(Position.ToString()); args["velocity"] = OSD.FromString(Velocity.ToString()); args["center"] = OSD.FromString(Center.ToString()); args["size"] = OSD.FromString(Size.ToString()); args["at_axis"] = OSD.FromString(AtAxis.ToString()); args["left_axis"] = OSD.FromString(LeftAxis.ToString()); args["up_axis"] = OSD.FromString(UpAxis.ToString()); //backwards compatibility args["changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["far"] = OSD.FromReal(Far); args["aspect"] = OSD.FromReal(Aspect); if ((Throttles != null) && (Throttles.Length > 0)) args["throttles"] = OSD.FromBinary(Throttles); args["locomotion_state"] = OSD.FromString(LocomotionState.ToString()); args["head_rotation"] = OSD.FromString(HeadRotation.ToString()); args["body_rotation"] = OSD.FromString(BodyRotation.ToString()); args["control_flags"] = OSD.FromString(ControlFlags.ToString()); args["energy_level"] = OSD.FromReal(EnergyLevel); args["god_level"] = OSD.FromString(GodLevel.ToString()); args["always_run"] = OSD.FromBoolean(AlwaysRun); args["prey_agent"] = OSD.FromUUID(PreyAgent); args["agent_access"] = OSD.FromString(AgentAccess.ToString()); args["active_group_id"] = OSD.FromUUID(ActiveGroupID); if ((Groups != null) && (Groups.Length > 0)) { OSDArray groups = new OSDArray(Groups.Length); foreach (AgentGroupData agd in Groups) groups.Add(agd.PackUpdateMessage()); args["groups"] = groups; } if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } args["children_seeds"] = childrenSeeds; } if ((Anims != null) && (Anims.Length > 0)) { OSDArray anims = new OSDArray(Anims.Length); foreach (Animation aanim in Anims) anims.Add(aanim.PackUpdateMessage()); args["animations"] = anims; } if (DefaultAnim != null) { args["default_animation"] = DefaultAnim.PackUpdateMessage(); } if (AnimState != null) { args["animation_state"] = AnimState.PackUpdateMessage(); } if (MovementAnimationOverRides.Count > 0) { OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count); { foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides) { OSDMap ao = new OSDMap(2); ao["state"] = OSD.FromString(kvp.Key); ao["uuid"] = OSD.FromUUID(kvp.Value); AOs.Add(ao); } } args["movementAO"] = AOs; } if (MotionState != 0) { args["motion_state"] = OSD.FromInteger(MotionState); } if (Appearance != null) args["packed_appearance"] = Appearance.Pack(ctx); //if ((AgentTextures != null) && (AgentTextures.Length > 0)) //{ // OSDArray textures = new OSDArray(AgentTextures.Length); // foreach (UUID uuid in AgentTextures) // textures.Add(OSD.FromUUID(uuid)); // args["agent_textures"] = textures; //} // The code to pack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only /* then lets remove if (Appearance.Texture != null) { byte[] rawtextures = Appearance.Texture.GetBytes(); args["texture_entry"] = OSD.FromBinary(rawtextures); } if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) args["visual_params"] = OSD.FromBinary(Appearance.VisualParams); // We might not pass this in all cases... if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) { OSDArray wears = new OSDArray(Appearance.Wearables.Length); foreach (AvatarWearable awear in Appearance.Wearables) wears.Add(awear.Pack()); args["wearables"] = wears; } List<AvatarAttachment> attachments = Appearance.GetAttachments(); if ((attachments != null) && (attachments.Count > 0)) { OSDArray attachs = new OSDArray(attachments.Count); foreach (AvatarAttachment att in attachments) attachs.Add(att.Pack()); args["attachments"] = attachs; } // End of code to remove */ if ((Controllers != null) && (Controllers.Length > 0)) { OSDArray controls = new OSDArray(Controllers.Length); foreach (ControllerData ctl in Controllers) controls.Add(ctl.PackUpdateMessage()); args["controllers"] = controls; } if ((CallbackURI != null) && (!CallbackURI.Equals(""))) args["callback_uri"] = OSD.FromString(CallbackURI); // Attachment objects for fatpack messages if (AttachmentObjects != null) { int i = 0; OSDArray attObjs = new OSDArray(AttachmentObjects.Count); foreach (ISceneObject so in AttachmentObjects) { OSDMap info = new OSDMap(4); info["sog"] = OSD.FromString(so.ToXml2()); info["extra"] = OSD.FromString(so.ExtraToXmlString()); info["modified"] = OSD.FromBoolean(so.HasGroupChanged); try { info["state"] = OSD.FromString(AttachmentObjectStates[i++]); } catch (IndexOutOfRangeException) { m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list."); } attObjs.Add(info); } args["attach_objects"] = attObjs; } args["parent_part"] = OSD.FromUUID(ParentPart); args["sit_offset"] = OSD.FromString(SitOffset.ToString()); return args; }