/// ----------------------------------------------------------------- /// <summary> /// </summary> // ----------------------------------------------------------------- public ResponseBase SetAvatarAppearanceHandler(RequestBase irequest) { if (irequest.GetType() != typeof(SetAvatarAppearanceRequest)) return OperationFailed("wrong type"); SetAvatarAppearanceRequest request = (SetAvatarAppearanceRequest)irequest; // Get the scenepresence for the avatar we are going to update UUID id = request.AvatarID == UUID.Zero ? request._UserAccount.PrincipalID : request.AvatarID; ScenePresence sp = m_scene.GetScenePresence(id); if (sp == null || sp.IsChildAgent) return OperationFailed(String.Format("cannot find user {0}",request._UserAccount.PrincipalID)); // Clean out the current outfit folder, this is to keep v3 viewers from // reloading the old appearance CleanCurrentOutfitFolder(sp); // Delete existing npc attachments m_scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); // ---------- Update the appearance and save it ---------- int serial = sp.Appearance.Serial; OSDMap osd = (OSDMap)OSDParser.DeserializeJson(request.SerializedAppearance); sp.Appearance = new AvatarAppearance(osd); sp.Appearance.Serial = serial + 1; m_scene.AvatarService.SetAppearance(sp.UUID,sp.Appearance); m_scene.EventManager.TriggerAvatarAppearanceChanged(sp); // ---------- Send out the new appearance to everyone ---------- // Rez needed attachments m_scene.AttachmentsModule.RezAttachments(sp); // this didn't work, still looking for a way to get the viewer to change its appearance //sp.ControllingClient.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); // this didn't work either, //AddWearablesToCurrentOutfitFolder(sp); sp.SendAvatarDataToAllClients(); sp.SendAppearanceToAllOtherClients(); sp.SendAppearanceToClient(sp); // the viewers seem to ignore this packet when it describes their own avatar return new ResponseBase(ResponseCode.Success,""); }