public void AnimationOSDTest() { Assert.That(anim1.AnimID == animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum == 1, "The Animation Constructor didn't set the fields correctly"); OSD updateMessage = anim1.PackUpdateMessage(); Assert.That(updateMessage is OSDMap, "Packed UpdateMessage isn't an OSDMap"); OSDMap updateMap = (OSDMap)updateMessage; Assert.That(updateMap.ContainsKey("animation"), "Packed Message doesn't contain an animation element"); Assert.That(updateMap.ContainsKey("object_id"), "Packed Message doesn't contain an object_id element"); Assert.That(updateMap.ContainsKey("seq_num"), "Packed Message doesn't contain a seq_num element"); Assert.That(updateMap["animation"].AsUUID() == animUUID1); Assert.That(updateMap["object_id"].AsUUID() == objUUID1); Assert.That(updateMap["seq_num"].AsInteger() == 1); Animation anim3 = new Animation(updateMap); Assert.That(anim3.ObjectID == anim1.ObjectID && anim3.AnimID == anim1.AnimID && anim3.SequenceNum == anim1.SequenceNum, "OSDMap Constructor failed to set the properties correctly."); anim3.UnpackUpdateMessage(anim2.PackUpdateMessage()); Assert.That(anim3.ObjectID == objUUID2 && anim3.AnimID == animUUID2 && anim3.SequenceNum == 1, "Animation.UnpackUpdateMessage failed to set the properties correctly."); Animation anim4 = new Animation(); anim4.AnimID = anim2.AnimID; anim4.ObjectID = anim2.ObjectID; anim4.SequenceNum = anim2.SequenceNum; Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); }
public void AnimationOSDTest() { Assert.That(anim1.AnimID==animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum ==1, "The Animation Constructor didn't set the fields correctly"); OSD updateMessage = anim1.PackUpdateMessage(); Assert.That(updateMessage is OSDMap, "Packed UpdateMessage isn't an OSDMap"); OSDMap updateMap = (OSDMap) updateMessage; Assert.That(updateMap.ContainsKey("animation"), "Packed Message doesn't contain an animation element"); Assert.That(updateMap.ContainsKey("object_id"), "Packed Message doesn't contain an object_id element"); Assert.That(updateMap.ContainsKey("seq_num"), "Packed Message doesn't contain a seq_num element"); Assert.That(updateMap["animation"].AsUUID() == animUUID1); Assert.That(updateMap["object_id"].AsUUID() == objUUID1); Assert.That(updateMap["seq_num"].AsInteger() == 1); Animation anim3 = new Animation(updateMap); Assert.That(anim3.ObjectID == anim1.ObjectID && anim3.AnimID == anim1.AnimID && anim3.SequenceNum == anim1.SequenceNum, "OSDMap Constructor failed to set the properties correctly."); anim3.UnpackUpdateMessage(anim2.PackUpdateMessage()); Assert.That(anim3.ObjectID == objUUID2 && anim3.AnimID == animUUID2 && anim3.SequenceNum == 1, "Animation.UnpackUpdateMessage failed to set the properties correctly."); Animation anim4 = new Animation(); anim4.AnimID = anim2.AnimID; anim4.ObjectID = anim2.ObjectID; anim4.SequenceNum = anim2.SequenceNum; Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); }
public void Setup() { animUUID1 = UUID.Random(); animUUID2 = UUID.Random(); objUUID1 = UUID.Random(); objUUID2 = UUID.Random(); anim1 = new Animation(animUUID1, 1, objUUID1); anim2 = new Animation(animUUID2, 1, objUUID2); }
public void Setup() { animUUID1 = UUID.Random(); animUUID2 = UUID.Random(); objUUID1 = UUID.Random(); objUUID2 = UUID.Random(); anim1 = new Animation(animUUID1, 1, objUUID1); anim2 = new Animation(animUUID2, 1, objUUID2); }
/// <summary> /// The default animation is reserved for "main" animations /// that are mutually exclusive, e.g. flying and sitting. /// </summary> public bool SetDefaultAnimation(UUID animID, int sequenceNum, UUID objectID) { bool rc = false; lock (m_defaultAnimation) { if (m_defaultAnimation.AnimID != animID) { m_defaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); rc = true; } } // if (!rc) m_log.ErrorFormat("SetDefaultAnimation: Animation '{0}' already set.", animID.ToString()); return(rc); }
public void FromArray(OpenSim.Framework.Animation[] theArray) { m_animations.Clear(); if (theArray == null) { return; // no work to do, leave m_animations as is } uint i = 0; foreach (OpenSim.Framework.Animation anim in theArray) { if (++i == theArray.Length) { m_defaultAnimation = anim; } else { m_animations.Add(anim); } } }
public OpenSim.Framework.Animation[] ToArray() { OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count + 1]; if (m_animations == null) { return(theArray); // let's try to keep known s%^t from happening } uint i = 0; try { foreach (OpenSim.Framework.Animation anim in m_animations) { theArray[i++] = anim; } theArray[i++] = m_defaultAnimation; } catch { /* S%^t happens. Ignore. */ } return(theArray); }
public void FromArray(OpenSim.Framework.Animation[] theArray) { m_animations.Clear(); if (theArray == null) return; // no work to do, leave m_animations as is uint i = 0; foreach (OpenSim.Framework.Animation anim in theArray) { if (++i == theArray.Length) m_defaultAnimation = anim; else m_animations.Add(anim); } }
public OpenSim.Framework.Animation[] ToArray() { OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count+1]; if (m_animations == null) return theArray; // let's try to keep known s%^t from happening uint i = 0; try { foreach (OpenSim.Framework.Animation anim in m_animations) theArray[i++] = anim; theArray[i++] = m_defaultAnimation; } catch { /* S%^t happens. Ignore. */ } return theArray; }
/// <summary> /// The default animation is reserved for "main" animations /// that are mutually exclusive, e.g. flying and sitting. /// </summary> public bool SetDefaultAnimation(UUID animID, int sequenceNum, UUID objectID) { bool rc = false; lock (m_defaultAnimation) { if (m_defaultAnimation.AnimID != animID) { m_defaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); rc = true; } } // if (!rc) m_log.ErrorFormat("SetDefaultAnimation: Animation '{0}' already set.", animID.ToString()); return rc; }
/// <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"); OSD tmp; if (args.TryGetValue("region_id", out tmp) && tmp != null) { UUID.TryParse(tmp.AsString(), out RegionID); } if (args.TryGetValue("circuit_code", out tmp) && tmp != null) { UInt32.TryParse(tmp.AsString(), out CircuitCode); } if (args.TryGetValue("agent_uuid", out tmp) && tmp != null) { AgentID = tmp.AsUUID(); } if (args.TryGetValue("session_uuid", out tmp) && tmp != null) { SessionID = tmp.AsUUID(); } if (args.TryGetValue("position", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out Position); } if (args.TryGetValue("velocity", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out Velocity); } if (args.TryGetValue("center", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out Center); } if (args.TryGetValue("size", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out Size); } if (args.TryGetValue("at_axis", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out AtAxis); } if (args.TryGetValue("left_axis", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out AtAxis); } if (args.TryGetValue("up_axis", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out AtAxis); } if (args.TryGetValue("wait_for_root", out tmp) && tmp != null) { SenderWantsToWaitForRoot = tmp.AsBoolean(); } if (args.TryGetValue("far", out tmp) && tmp != null) { Far = (float)(tmp.AsReal()); } if (args.TryGetValue("aspect", out tmp) && tmp != null) { Aspect = (float)tmp.AsReal(); } if (args.TryGetValue("throttles", out tmp) && tmp != null) { Throttles = tmp.AsBinary(); } if (args.TryGetValue("locomotion_state", out tmp) && tmp != null) { UInt32.TryParse(tmp.AsString(), out LocomotionState); } if (args.TryGetValue("head_rotation", out tmp) && tmp != null) { Quaternion.TryParse(tmp.AsString(), out HeadRotation); } if (args.TryGetValue("body_rotation", out tmp) && tmp != null) { Quaternion.TryParse(tmp.AsString(), out BodyRotation); } if (args.TryGetValue("control_flags", out tmp) && tmp != null) { UInt32.TryParse(tmp.AsString(), out ControlFlags); } if (args.TryGetValue("energy_level", out tmp) && tmp != null) { EnergyLevel = (float)(tmp.AsReal()); } if (args.TryGetValue("god_data", out tmp) && tmp != null) { GodData = tmp; } if (args.TryGetValue("always_run", out tmp) && tmp != null) { AlwaysRun = tmp.AsBoolean(); } if (args.TryGetValue("prey_agent", out tmp) && tmp != null) { PreyAgent = tmp.AsUUID(); } if (args.TryGetValue("agent_access", out tmp) && tmp != null) { Byte.TryParse(tmp.AsString(), out AgentAccess); } if (args.TryGetValue("agent_cof", out tmp) && tmp != null) { agentCOF = tmp.AsUUID(); } if (args.TryGetValue("crossingflags", out tmp) && tmp != null) { CrossingFlags = (byte)tmp.AsInteger(); } if (CrossingFlags != 0) { if (args.TryGetValue("crossExtraFlags", out tmp) && tmp != null) { CrossExtraFlags = (byte)tmp.AsInteger(); } } if (args.TryGetValue("active_group_id", out tmp) && tmp != null) { ActiveGroupID = tmp.AsUUID(); } if (args.TryGetValue("active_group_name", out tmp) && tmp != null) { ActiveGroupName = tmp.AsString(); } if (args.TryGetValue("active_group_title", out tmp) && tmp != null) { ActiveGroupTitle = tmp.AsString(); } if (args.TryGetValue("children_seeds", out tmp) && tmp is OSDArray) { OSDArray childrenSeeds = (OSDArray)tmp; ChildrenCapSeeds = new Dictionary <ulong, string>(); foreach (OSD o in childrenSeeds) { if (o is OSDMap) { ulong handle = 0; string seed = ""; OSDMap pair = (OSDMap)o; if (pair.TryGetValue("handle", out tmp)) { if (!UInt64.TryParse(tmp.AsString(), out handle)) { continue; } } if (pair.TryGetValue("seed", out tmp)) { seed = tmp.AsString(); } if (!ChildrenCapSeeds.ContainsKey(handle)) { ChildrenCapSeeds.Add(handle, seed); } } } } if (args.TryGetValue("animations", out tmp) && tmp is OSDArray) { OSDArray anims = (OSDArray)tmp; Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o is OSDMap) { Anims[i++] = new Animation((OSDMap)o); } } } if (args.TryGetValue("default_animation", out tmp) && tmp is OSDMap) { try { DefaultAnim = new Animation((OSDMap)tmp); } catch { DefaultAnim = null; } } if (args.TryGetValue("animation_state", out tmp) && tmp is OSDMap) { try { AnimState = new Animation((OSDMap)tmp); } catch { AnimState = null; } } MovementAnimationOverRides.Clear(); if (args.TryGetValue("movementAO", out tmp) && tmp is OSDArray) { OSDArray AOs = (OSDArray)tmp; 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.TryGetValue("motion_state", out tmp) && tmp != null) { MotionState = (byte)tmp.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.TryGetValue("packed_appearance", out tmp) && tmp is OSDMap) { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance"); Appearance = new AvatarAppearance((OSDMap)tmp); } 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.TryGetValue("texture_entry", out tmp) && tmp != null) { byte[] rawtextures = tmp.AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args.TryGetValue("visual_params", out tmp) && tmp != null) { Appearance.SetVisualParams(tmp.AsBinary()); } if (args.TryGetValue("wearables", out tmp) && tmp is OSDArray) { OSDArray wears = (OSDArray)tmp; for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if (args.TryGetValue("attachments", out tmp) && tmp is OSDArray) { OSDArray attachs = (OSDArray)tmp; foreach (OSD o in attachs) { if (o is OSDMap) { // 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 } if (args.TryGetValue("controllers", out tmp) && tmp is OSDArray) { OSDArray controls = (OSDArray)tmp; Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o is OSDMap) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args.TryGetValue("callback_uri", out tmp) && tmp != null) { CallbackURI = tmp.AsString(); } if (args.TryGetValue("cb_uri", out tmp) && tmp != null) { NewCallbackURI = tmp.AsString(); } // Attachment objects if (args.TryGetValue("attach_objects", out tmp) && tmp is OSDArray) { OSDArray attObjs = (OSDArray)tmp; AttachmentObjects = new List <ISceneObject>(); AttachmentObjectStates = new List <string>(); foreach (OSD o in attObjs) { if (o is OSDMap) { 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.TryGetValue("parent_part", out tmp) && tmp != null) { ParentPart = tmp.AsUUID(); } if (args.TryGetValue("sit_offset", out tmp) && tmp != null) { Vector3.TryParse(tmp.AsString(), out SitOffset); } }
public void FromArray(Animation[] theArray) { foreach (Animation anim in theArray) m_animations.Add(anim); }
public Animation[] ToArray() { Animation[] theArray = new Animation[m_animations.Count]; uint i = 0; try { foreach (Animation anim in m_animations) theArray[i++] = anim; } catch { /* S%^t happens. Ignore. */ } return theArray; }
/// <summary> /// The default animation is reserved for "main" animations /// that are mutually exclusive, e.g. flying and sitting. /// </summary> public bool SetDefaultAnimation(UUID animID, int sequenceNum, UUID objectID) { if (m_defaultAnimation.AnimID != animID) { m_defaultAnimation = new Animation(animID, sequenceNum, objectID); return true; } return false; }