public void AvatarAnimationHandler(OpenMetaverse.Packets.Packet packet, Simulator sim) { // When animations for any avatar are received put them in the AvatarAnimations dictionary // in this module. They should be processed and deleted inbetween frames in the main frame loop // or deleted when an avatar is deleted from the scene. AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; UUID avatarID = animation.Sender.ID; List <UUID> currentAnims = new List <UUID>(); for (int i = 0; i < animation.AnimationList.Length; i++) { currentAnims.Add(animation.AnimationList[i].AnimID); } lock (AvatarAnimations) { if (AvatarAnimations.ContainsKey(avatarID)) { AvatarAnimations[avatarID] = currentAnims; } else { AvatarAnimations.Add(avatarID, currentAnims); } } }
// Processes the avatar animation packet (and overrides the animations if AO is active) private Packet ProcessAvatarAnimation(Packet packet, IPEndPoint endpoint) { AvatarAnimationPacket animations = (AvatarAnimationPacket)packet; if (animations.Sender.ID == monitored) { for (int i = 0; i < animations.AnimationList.Length; i++) { string animname; if (KeyToAnim.TryGetValue(animations.AnimationList[i].AnimID, out animname)) { } else { animname = "Unknown"; if (!animFound.ContainsKey(animations.AnimationList[i].AnimID)) { animFound.Add(animations.AnimationList[i].AnimID, string.Format("Ag. anim {0}: {1} {2}", i, animations.AnimationList[i].AnimID, animname)); SayToUser(string.Format("Ag. anim {0}: {1} {2}", i, animations.AnimationList[i].AnimID, animname)); animRead++; textMonTot.Text = animRead.ToString(); } } } } return(packet); }
/// <summary> /// Process incoming avatar animations /// </summary> /// <param name="packet"></param> /// <param name="sim"></param> private void AvatarAnimationHandler(object sender, PacketReceivedEventArgs e) { var sim = e.Simulator; var packet = e.Packet; if (!IsMaster(sim)) { return; } AvatarAnimationPacket data = (AvatarAnimationPacket)packet; List <Animation> signaledAnimations = new List <Animation>(data.AnimationList.Length); for (int i = 0; i < data.AnimationList.Length; i++) { Animation animation = new Animation(); animation.AnimationID = data.AnimationList[i].AnimID; animation.AnimationSequence = data.AnimationList[i].AnimSequenceID; if (i < data.AnimationSourceList.Length) { animation.AnimationSourceObjectID = data.AnimationSourceList[i].ObjectID; } signaledAnimations.Add(animation); } Avatars_OnAvatarAnimation(this, new AvatarAnimationEventArgs(data.Sender.ID, signaledAnimations)); }
//return the name of an animation by its UUID // private string animname(UUID arg) // { // return animuid2name[arg]; // } //handle animation packets from simulator private Packet AnimationPacketHandler(Packet packet, IPEndPoint sim) { AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; if (animation.Sender.ID == frame.AgentID) { //the received animation packet is about our Agent, handle it lock (SignaledAnimations) { // Reset the signaled animation list SignaledAnimations.Clear(); //fill it with the fresh list from simulator for (int i = 0; i < animation.AnimationList.Length; i++) { UUID animID = animation.AnimationList[i].AnimID; int sequenceID = animation.AnimationList[i].AnimSequenceID; // Add this animation to the list of currently signaled animations SignaledAnimations[animID] = sequenceID; //SayToUser("Animation: " + animname(animID)); } } //we now have a list of currently running animations //Start override animations if necessary foreach (UUID key in overrides.Keys) { //For each overriden animation key, test if its override is running if (SignaledAnimations.ContainsKey(key) && (!overrideanimationisplaying[key])) { //An overriden animation is present and its override animation //isnt currently playing //Start the override animation //SayToUser("animation " + animname(key) + " started, will override with " + animname(overrides[key])); overrideanimationisplaying[key] = true; Animate(overrides[key], true); } else if ((!SignaledAnimations.ContainsKey(key)) && overrideanimationisplaying[key]) { //an override animation is currently playing, but it's overriden //animation is not. //stop the override animation //SayToUser("animation " + animname(key) + " stopped, will override with " + animname(overrides[key])); overrideanimationisplaying[key] = false; Animate(overrides[key], false); } } } //Let the packet go to the client return(packet); }
/// <summary> /// Process incoming avatar animations /// </summary> /// <param name="packet"></param> /// <param name="sim"></param> private void AvatarAnimationHandler(Packet packet, Simulator sim) { if (OnAvatarAnimation != null) { AvatarAnimationPacket anims = (AvatarAnimationPacket)packet; InternalDictionary <UUID, int> signaledAnims = new InternalDictionary <UUID, int>(); for (int i = 0; i < anims.AnimationList.Length; i++) { signaledAnims.Add(anims.AnimationList[i].AnimID, anims.AnimationList[i].AnimSequenceID); } try { OnAvatarAnimation(anims.Sender.ID, signaledAnims); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } }
// Sends animation update public void SendAnimPack() { AvatarAnimationPacket ani = new AvatarAnimationPacket(); ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID; ani.Sender = new AvatarAnimationPacket.SenderBlock(); ani.Sender.ID = ControllingClient.AgentID; ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); ani.AnimationList[0].AnimID = this.current_anim; ani.AnimationList[0].AnimSequenceID = this.anim_seq; //ControllingClient.OutPacket(ani); foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(ani); } }
public void SendAnimations(Agent agent) { AvatarAnimationPacket sendAnim = new AvatarAnimationPacket(); sendAnim.Sender.ID = agent.AgentID; sendAnim.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; sendAnim.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); sendAnim.AnimationSourceList[0].ObjectID = agent.AgentID; UUID[] animIDS; int[] sequenceNums; agent.Animations.GetArrays(out animIDS, out sequenceNums); sendAnim.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animIDS.Length]; for (int i = 0; i < animIDS.Length; i++) { sendAnim.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock(); sendAnim.AnimationList[i].AnimID = animIDS[i]; sendAnim.AnimationList[i].AnimSequenceID = sequenceNums[i]; } server.UDP.BroadcastPacket(sendAnim, PacketCategory.State); }
private void SendAvatarAnimationPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence) { if (!(presence is LLAgent) || presence.InterestList == null) { return; } LLAgent agent = (LLAgent)presence; for (int i = 0; i < eventDatas.Length; i++) { LLAgent animAgent = (LLAgent)eventDatas[i].Event.State; AvatarAnimationPacket packet = new AvatarAnimationPacket(); packet.Sender.ID = animAgent.ID; Animation[] animations = animAgent.Animations.GetAnimations(); packet.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length]; for (int j = 0; j < animations.Length; j++) { Animation animation = animations[j]; packet.AnimationList[j] = new AvatarAnimationPacket.AnimationListBlock { AnimID = animation.ID, AnimSequenceID = animation.SequenceNum }; } packet.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; packet.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock { ObjectID = animAgent.ID }; packet.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0]; m_udp.SendPacket(agent, packet, ThrottleCategory.Task, false); } }
private void SendAvatarAnimationPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence) { if (!(presence is LLAgent) || presence.InterestList == null) return; LLAgent agent = (LLAgent)presence; for (int i = 0; i < eventDatas.Length; i++) { LLAgent animAgent = (LLAgent)eventDatas[i].Event.State; AvatarAnimationPacket packet = new AvatarAnimationPacket(); packet.Sender.ID = animAgent.ID; Animation[] animations = animAgent.Animations.GetAnimations(); packet.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length]; for (int j = 0; j < animations.Length; j++) { Animation animation = animations[j]; packet.AnimationList[j] = new AvatarAnimationPacket.AnimationListBlock { AnimID = animation.ID, AnimSequenceID = animation.SequenceNum }; } packet.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; packet.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock { ObjectID = animAgent.ID }; packet.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0]; m_udp.SendPacket(agent, packet, ThrottleCategory.Task, false); } }
public void ObjectAnimate(object sender, UUID senderID, UUID objectID, AnimationTrigger[] animations) { if (OnObjectAnimate != null) { OnObjectAnimate(sender, senderID, objectID, animations); } AvatarAnimationPacket sendAnim = new AvatarAnimationPacket(); sendAnim.Sender.ID = senderID; sendAnim.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; sendAnim.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); sendAnim.AnimationSourceList[0].ObjectID = objectID; sendAnim.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length]; for (int i = 0; i < animations.Length; i++) { sendAnim.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock(); sendAnim.AnimationList[i].AnimID = animations[i].AnimationID; sendAnim.AnimationList[i].AnimSequenceID = animations[i].SequenceID; } udp.BroadcastPacket(sendAnim, PacketCategory.State); }