public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) { // MainConsole.Instance.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); m_serial = 1; m_owner = avatarID; if (wearables != null) m_wearables = wearables; else SetDefaultWearables(); if (textureEntry != null) m_texture = textureEntry; else SetDefaultTexture(); if (visualParams != null) m_visualparams = visualParams; else SetDefaultParams(); SetHeight(); m_attachments = new Dictionary<int, List<AvatarAttachment>>(); }
public int GetWearableType(UUID itemID) { AvatarWearable wearable = GetWearableForItem(itemID); if (wearable == null) { return(AvatarWearable.NONE); } else { return(wearable.WearableType); } }
public AvatarAppearance(UUID owner) { m_wearables = new AvatarWearable[MAX_WEARABLES]; for (int i = 0; i < MAX_WEARABLES; i++) { // this makes them all null m_wearables[i] = new AvatarWearable(); } m_serial = 0; m_owner = owner; m_visualparams = new byte[VISUALPARAM_COUNT]; // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist SetDefaultParams(m_visualparams); SetDefaultWearables(); m_texture = GetDefaultTexture(); }
public AvatarAppearance(Hashtable h) { Owner = new UUID((string)h["owner"]); Serial = Convert.ToInt32((string)h["serial"]); VisualParams = (byte[])h["visual_params"]; Texture = new Primitive.TextureEntry((byte[])h["texture"], 0, ((byte[])h["texture"]).Length); AvatarHeight = (float)Convert.ToDouble((string)h["avatar_height"]); m_wearables = new AvatarWearable[MAX_WEARABLES]; for (int i = 0; i < MAX_WEARABLES; i++) { // this makes them all null m_wearables[i] = new AvatarWearable(); } BodyItem = new UUID((string)h["body_item"]); BodyAsset = new UUID((string)h["body_asset"]); SkinItem = new UUID((string)h["skin_item"]); SkinAsset = new UUID((string)h["skin_asset"]); HairItem = new UUID((string)h["hair_item"]); HairAsset = new UUID((string)h["hair_asset"]); EyesItem = new UUID((string)h["eyes_item"]); EyesAsset = new UUID((string)h["eyes_asset"]); ShirtItem = new UUID((string)h["shirt_item"]); ShirtAsset = new UUID((string)h["shirt_asset"]); PantsItem = new UUID((string)h["pants_item"]); PantsAsset = new UUID((string)h["pants_asset"]); ShoesItem = new UUID((string)h["shoes_item"]); ShoesAsset = new UUID((string)h["shoes_asset"]); SocksItem = new UUID((string)h["socks_item"]); SocksAsset = new UUID((string)h["socks_asset"]); JacketItem = new UUID((string)h["jacket_item"]); JacketAsset = new UUID((string)h["jacket_asset"]); GlovesItem = new UUID((string)h["gloves_item"]); GlovesAsset = new UUID((string)h["gloves_asset"]); UnderShirtItem = new UUID((string)h["undershirt_item"]); UnderShirtAsset = new UUID((string)h["undershirt_asset"]); UnderPantsItem = new UUID((string)h["underpants_item"]); UnderPantsAsset = new UUID((string)h["underpants_asset"]); SkirtItem = new UUID((string)h["skirt_item"]); SkirtAsset = new UUID((string)h["skirt_asset"]); if (h.ContainsKey("attachments")) { SetAttachmentsString(h["attachments"].ToString()); } }
public void SetWearable(AvatarWearable wearable) { if ((wearable.WearableType < 0) || (wearable.WearableType >= AvatarWearable.MAX_WEARABLES)) { m_log.WarnFormat("[AVATAR APPEARANCE]: AvatarWearable type {0} is out of range", wearable.WearableType); return; } if (AvatarWearable.IsRequiredWearable(wearable.WearableType) && (wearable.ItemID == UUID.Zero)) { m_log.WarnFormat("[AVATAR APPEARANCE]: Refusing to set a ZERO wearable for a required item of type {0}", wearable.WearableType); return; } lock (m_wearables) { m_wearables[wearable.WearableType] = wearable; } }
public virtual void SendWearables(AvatarWearable[] wearables, int serial) { }
/// <summary> /// Unpack and OSDMap and initialize the appearance /// from it /// </summary> public void Unpack(OSDMap data) { if ((data != null) && (data["serial"] != null)) m_serial = data["serial"].AsInteger(); if ((data != null) && (data["height"] != null)) // m_avatarHeight = (float)data["height"].AsReal(); SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); try { // Wearables SetDefaultWearables(); if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(data["wearables"]); int count = wears.Count; m_wearables = new AvatarWearable[count]; for (int i = 0; i < count; i++) m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); } // Avatar Textures SetDefaultTexture(); if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array) { OSDArray textures = (OSDArray)(data["textures"]); for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) { UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; if (textures[i] != null) textureID = textures[i].AsUUID(); m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); } } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); } if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array) { OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]); m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray); } // Visual Parameters SetDefaultParams(); if ((data != null) && (data["visualparams"] != null)) { if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array)) m_visualparams = data["visualparams"].AsBinary(); } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters"); } // Attachments m_attachments = new Dictionary<int, List<AvatarAttachment>>(); if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(data["attachments"]); for (int i = 0; i < attachs.Count; i++) { AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); AppendAttachment(att); // m_log.DebugFormat( // "[AVATAR APPEARANCE]: Unpacked attachment itemID {0}, assetID {1}, point {2}", // att.ItemID, att.AssetID, att.AttachPoint); } } } catch (Exception e) { m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace); } }
public virtual void SetWearable(int wearableId, AvatarWearable wearable) { // DEBUG ON // m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); // DEBUG OFF if (wearableId >= m_wearables.Length) { int currentLength = m_wearables.Length; Array.Resize(ref m_wearables, wearableId + 1); for (int i = currentLength ; i < m_wearables.Length ; i++) m_wearables[i] = new AvatarWearable(); } m_wearables[wearableId].Clear(); for (int i = 0; i < wearable.Count; i++) m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); }
public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) { // m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance"); m_serial = 0; if (wearables != null) m_wearables = wearables; else SetDefaultWearables(); if (textureEntry != null) m_texture = textureEntry; else SetDefaultTexture(); if (visualParams != null) m_visualparams = visualParams; else SetDefaultParams(); // SetHeight(); if(m_avatarHeight == 0) SetSize(new Vector3(0.45f,0.6f,1.9f)); m_attachments = new Dictionary<int, List<AvatarAttachment>>(); }
/// <summary> /// This method is called by updateAvatarAppearance once any specified model has been /// ratified, or an appropriate default value has been adopted. The intended prototype /// is known to exist, as is the target avatar. /// </summary> private void establishAppearance(UUID dest, UUID srca) { m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); AvatarAppearance ava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(srca); // If the model has no associated appearance we're done. // if (ava == null) // { // return new AvatarAppearance(); // } if (ava == null) return; UICallback sic = new UICallback(); UICallback dic = new UICallback(); IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; try { Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>(); iserv.GetUserInventory(dest, dic.callback); iserv.GetUserInventory(srca, sic.callback); dic.GetInventory(); sic.GetInventory(); if (sic.OK && dic.OK) { InventoryFolderImpl efolder; InventoryFolderImpl srcf = sic.root.FindFolderForType(5); InventoryFolderImpl dstf = dic.root.FindFolderForType(5); if (srcf == null || dstf == null) throw new Exception("Cannot locate clothing folder(s)"); foreach (InventoryFolderImpl folder in sic.folders) { if (folder.ParentID == srcf.ID) { efolder = new InventoryFolderImpl(); efolder.ID = UUID.Random(); efolder.Name = folder.Name; efolder.Type = folder.Type; efolder.Version = folder.Version; efolder.Owner = dest; dstf.AddChildFolder(efolder); iserv.AddFolder(efolder); m_log.DebugFormat("[RADMIN] Added outfile folder {0} to folder {1}", efolder.ID, srcf.ID); foreach (InventoryItemBase item in sic.items) { if (item.Folder == folder.ID) { InventoryItemBase dsti = new InventoryItemBase(); dsti.ID = UUID.Random(); dsti.Name = item.Name; dsti.Description = item.Description; dsti.InvType = item.InvType; dsti.AssetType = item.AssetType; dsti.Flags = item.Flags; dsti.AssetID = item.AssetID; dsti.Folder = efolder.ID; dsti.Owner = dest; dsti.BasePermissions = item.BasePermissions; dsti.NextPermissions = item.NextPermissions; dsti.CurrentPermissions = item.CurrentPermissions; dsti.GroupPermissions = item.GroupPermissions; dsti.EveryOnePermissions = item.EveryOnePermissions; iserv.AddItem(dsti); imap.Add(item.ID, dsti.ID); m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID); } } } } // Update appearance tables AvatarWearable[] wearables = ava.Wearables; for (int i=0; i<wearables.Length; i++) { if (imap.ContainsKey(wearables[i].ItemID)) { AvatarWearable dw = new AvatarWearable(); dw.AssetID = wearables[i].AssetID; dw.ItemID = imap[wearables[i].ItemID]; ava.SetWearable(i, dw); } } } else { throw new Exception("Unable to load both inventories"); } m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava); } catch (Exception e) { m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}", dest, e.Message); return; } return; }
/// <summary> /// Tell the Avatar Service about these baked textures and items /// </summary> /// <param name="sp"></param> /// <param name="textureEntry"></param> /// <param name="wearables"></param> private void CacheWearableData(IScenePresence sp, Primitive.TextureEntry textureEntry, WearableCache[] wearables) { if (textureEntry == null || wearables.Length == 0) return; AvatarWearable cachedWearable = new AvatarWearable(); cachedWearable.MaxItems = 0; //Unlimited items for (int i = 0; i < wearables.Length; i++) { WearableCache item = wearables[i]; if (textureEntry.FaceTextures[item.TextureIndex] != null) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } } m_scene.AvatarService.CacheWearableData(sp.UUID, cachedWearable); }
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, AvatarWearable[] wearables) : this(client, world, reginfo) { m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); }
public virtual void SetWearable(int wearableId, AvatarWearable wearable) { // DEBUG ON // m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); // DEBUG OFF m_wearables[wearableId].Clear(); for (int i = 0; i < wearable.Count; i++) m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); }
/// <summary> /// This method is called by establishAppearance to do a copy all inventory items /// worn or attached to the Clothing inventory folder of the receiving avatar. /// In parallel the avatar wearables and attachments are updated. /// </summary> private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) { IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService; // Get Clothing folder of receiver InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, AssetType.Clothing); if (destinationFolder == null) throw new Exception("Cannot locate folder(s)"); // Missing destination folder? This should *never* be the case if (destinationFolder.Type != (short)AssetType.Clothing) { destinationFolder = new InventoryFolderBase(); destinationFolder.ID = UUID.Random(); destinationFolder.Name = "Clothing"; destinationFolder.Owner = destination; destinationFolder.Type = (short)AssetType.Clothing; destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID; destinationFolder.Version = 1; inventoryService.AddFolder(destinationFolder); // store base record m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; AvatarWearable wearable; for (int i=0; i<wearables.Length; i++) { wearable = wearables[i]; if (wearable[0].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(wearable[0].ItemID, source); item = inventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); destinationItem.Name = item.Name; destinationItem.Owner = destination; destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; destinationItem.BasePermissions = item.BasePermissions; destinationItem.EveryOnePermissions = item.EveryOnePermissions; destinationItem.GroupPermissions = item.GroupPermissions; destinationItem.AssetType = item.AssetType; destinationItem.AssetID = item.AssetID; destinationItem.GroupID = item.GroupID; destinationItem.GroupOwned = item.GroupOwned; destinationItem.SalePrice = item.SalePrice; destinationItem.SaleType = item.SaleType; destinationItem.Flags = item.Flags; destinationItem.CreationDate = item.CreationDate; destinationItem.Folder = destinationFolder.ID; ApplyNextOwnerPermissions(destinationItem); m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem); m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, wearable[0].AssetID); avatarAppearance.SetWearable(i, newWearable); } else { m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID); } } } // Attachments List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(itemID, source); item = inventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); destinationItem.Name = item.Name; destinationItem.Owner = destination; destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; destinationItem.BasePermissions = item.BasePermissions; destinationItem.EveryOnePermissions = item.EveryOnePermissions; destinationItem.GroupPermissions = item.GroupPermissions; destinationItem.AssetType = item.AssetType; destinationItem.AssetID = item.AssetID; destinationItem.GroupID = item.GroupID; destinationItem.GroupOwned = item.GroupOwned; destinationItem.SalePrice = item.SalePrice; destinationItem.SaleType = item.SaleType; destinationItem.Flags = item.Flags; destinationItem.CreationDate = item.CreationDate; destinationItem.Folder = destinationFolder.ID; ApplyNextOwnerPermissions(destinationItem); m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem); m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } }
protected virtual void SetDefaultWearables() { SetWearables(AvatarWearable.GetDefaultWearables()); }
/// <summary> /// Unpack and OSDMap and initialize the appearance /// from it /// </summary> public void Unpack(OSDMap data) { if (data == null) { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack avatar appearance"); return; } if (data.ContainsKey("owner")) { m_owner = data["owner"].AsUUID(); } else { m_owner = UUID.Zero; } if (data.ContainsKey("serial")) { m_serial = data["serial"].AsInteger(); } if (data.ContainsKey("height")) { m_avatarHeight = (float)data["height"].AsReal(); } try { // Wearablles m_wearables = new Dictionary <int, AvatarWearable>(); ClearWearables(); if (data.ContainsKey("wearables") && ((data["wearables"]).Type == OSDType.Array)) { OSDArray wears = (OSDArray)data["wearables"]; for (int i = 0; i < wears.Count; i++) { AvatarWearable wearable = new AvatarWearable((OSDMap)wears[i]); SetWearable(wearable); } } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); } // Avatar Textures SetDefaultTexture(); if (data.ContainsKey("textures") && ((data["textures"]).Type == OSDType.Array)) { OSDArray textures = (OSDArray)(data["textures"]); for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) { UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; if (textures[i] != null) { textureID = textures[i].AsUUID(); } m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); } } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); } // Visual Parameters SetDefaultParams(); if (data.ContainsKey("visualparams")) { if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array)) { m_visualparams = data["visualparams"].AsBinary(); } } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters"); } // Attachments m_attachments = new Dictionary <int, List <AvatarAttachment> >(); if (data.ContainsKey("attachments") && ((data["attachments"]).Type == OSDType.Array)) { OSDArray attachs = (OSDArray)(data["attachments"]); for (int i = 0; i < attachs.Count; i++) { AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); AppendAttachment(att); } } } catch (Exception e) { m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace); } }
/// <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) { if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); } 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 ["active_group_id"] != null) { ActiveGroupID = args ["active_group_id"].AsUUID(); } if ((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 ["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; } } //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(); //} 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 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()); } } } }
public virtual void SetWearable(int wearableId, AvatarWearable wearable) { m_wearables[wearableId] = wearable; }
public AvatarAppearance(AvatarAppearance appearance, bool copyWearables) { // m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); if (appearance == null) { m_serial = 1; m_owner = UUID.Zero; SetDefaultWearables(); SetDefaultTexture(); SetDefaultParams(); SetHeight(); m_attachments = new Dictionary<int, List<AvatarAttachment>>(); return; } m_serial = appearance.Serial; m_owner = appearance.Owner; m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) m_wearables[i] = new AvatarWearable(); if (copyWearables && (appearance.Wearables != null)) { for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) SetWearable(i, appearance.Wearables[i]); } m_texture = null; if (appearance.Texture != null) { byte[] tbytes = appearance.Texture.GetBytes(); m_texture = new Primitive.TextureEntry(tbytes, 0, tbytes.Length); } m_visualparams = null; if (appearance.VisualParams != null) m_visualparams = (byte[])appearance.VisualParams.Clone(); // Copy the attachment, force append mode since that ensures consistency m_attachments = new Dictionary<int, List<AvatarAttachment>>(); foreach (AvatarAttachment attachment in appearance.GetAttachments()) AppendAttachment(new AvatarAttachment(attachment)); }
public virtual OSDMap Pack() { OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); 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["changed_grid"] = OSD.FromBoolean(ChangedGrid); 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 ((Anims != null) && (Anims.Length > 0)) { OSDArray anims = new OSDArray(Anims.Length); foreach (Animation aanim in Anims) { anims.Add(aanim.PackUpdateMessage()); } args["animations"] = anims; } if ((Appearance != null) && (Appearance.Texture != null)) { args["texture_entry"] = OSD.FromBinary(Appearance.Texture.GetBytes()); } if ((Appearance != null) && (Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) { args["visual_params"] = OSD.FromBinary(Appearance.VisualParams); } // We might not pass this in all cases... if (Appearance != null) { OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES * 2); for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) { AvatarWearable wearable = Appearance.GetWearableOfType(i); wears.Add(OSD.FromUUID(wearable.ItemID)); wears.Add(OSD.FromUUID(wearable.AssetID)); } args["wearables"] = wears; } if (!String.IsNullOrEmpty(CallbackURI)) { args["callback_uri"] = OSD.FromString(CallbackURI); } if (SatOnGroup != UUID.Zero) { args["sat_on_group"] = OSD.FromUUID(SatOnGroup); args["sat_on_prim"] = OSD.FromUUID(SatOnPrim); args["sit_offset"] = OSD.FromString(SatOnPrimOffset.ToString()); } 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) { //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["changed_grid"] != null) ChangedGrid = args["changed_grid"].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["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if ((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["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["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(); //} 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 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()); } } } }
private void RemapWornItems(UUID botID, AvatarAppearance appearance) { // save before Clear calls List<AvatarWearable> wearables = appearance.GetWearables(); List<AvatarAttachment> attachments = appearance.GetAttachments(); appearance.ClearWearables(); appearance.ClearAttachments(); // Remap bot outfit with new item IDs foreach (AvatarWearable w in wearables) { AvatarWearable newWearable = new AvatarWearable(w); // store a reversible back-link to the original inventory item ID. newWearable.ItemID = w.ItemID ^ botID; appearance.SetWearable(newWearable); } foreach (AvatarAttachment a in attachments) { // store a reversible back-link to the original inventory item ID. UUID itemID = a.ItemID ^ botID; appearance.SetAttachment(a.AttachPoint, true, itemID, a.AssetID); } }
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) { visualParams = AvatarAppearance.GetDefaultVisualParams(); wearables = AvatarWearable.DefaultWearables; }
/// <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) { // DEBUG ON m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data"); // DEBUG OFF 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["changed_grid"] != null) { ChangedGrid = args["changed_grid"].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["active_group_id"] != null) { ActiveGroupID = args["active_group_id"].AsUUID(); } if ((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["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["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(); //} Appearance = new AvatarAppearance(AgentID); // 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 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) { Appearance = new AvatarAppearance(AgentID, (OSDMap)args["packed_appearance"]); } // DEBUG ON else { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); } // DEBUG OFF 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(); } }
/// <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["active_group_id"] != null) { ActiveGroupID = args["active_group_id"].AsUUID(); } if ((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); } }
/// <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); }
///<summary> /// This method is called if a given model avatar name can not be found. If the external /// file has already been loaded once, then control returns immediately. If not, then it /// looks for a default appearance file. This file contains XML definitions of zero or more named /// avatars, each avatar can specify zero or more "outfits". Each outfit is a collection /// of items that together, define a particular ensemble for the avatar. Each avatar should /// indicate which outfit is the default, and this outfit will be automatically worn. The /// other outfits are provided to allow "real" avatars a way to easily change their outfits. /// </summary> private bool createDefaultAvatars() { // Only load once if (daload) { return false; } m_log.DebugFormat("[RADMIN] Creating default avatar entries"); daload = true; // Load processing starts here... try { string dafn = null; //m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini if (m_config != null) { dafn = m_config.GetString("default_appearance", "default_appearance.xml"); } if (File.Exists(dafn)) { XmlDocument doc = new XmlDocument(); string name = "*unknown*"; string email = "anon@anon"; uint regX = 1000; uint regY = 1000; string passwd = UUID.Random().ToString(); // No requirement to sign-in. CachedUserInfo UI; UUID ID = UUID.Zero; AvatarAppearance mava; XmlNodeList avatars; XmlNodeList assets; XmlNode perms = null; bool include = false; bool select = false; UICallback uic; IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; IAssetService aserv = m_app.SceneManager.CurrentOrFirstScene.AssetService; doc.LoadXml(File.ReadAllText(dafn)); // Load up any included assets. Duplicates will be ignored assets = doc.GetElementsByTagName("RequiredAsset"); foreach (XmlNode asset in assets) { AssetBase rass = new AssetBase(); rass.FullID = UUID.Random(); rass.Name = GetStringAttribute(asset,"name",""); rass.Description = GetStringAttribute(asset,"desc",""); rass.Type = SByte.Parse(GetStringAttribute(asset,"type","")); rass.Local = Boolean.Parse(GetStringAttribute(asset,"local","")); rass.Temporary = Boolean.Parse(GetStringAttribute(asset,"temporary","")); rass.Data = Convert.FromBase64String(asset.InnerText); aserv.Store(rass); } avatars = doc.GetElementsByTagName("Avatar"); // The document may contain multiple avatars foreach (XmlElement avatar in avatars) { m_log.DebugFormat("[RADMIN] Loading appearance for {0}, gender = {1}", GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?")); // Create the user identified by the avatar entry try { // Only the name value is mandatory name = GetStringAttribute(avatar,"name",name); email = GetStringAttribute(avatar,"email",email); regX = GetUnsignedAttribute(avatar,"regx",regX); regY = GetUnsignedAttribute(avatar,"regy",regY); passwd = GetStringAttribute(avatar,"password",passwd); string[] nomens = name.Split(); UI = m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(nomens[0], nomens[1]); if (null == UI) { ID = m_app.CommunicationsManager.UserAdminService.AddUser(nomens[0], nomens[1], passwd, email, regX, regY); if (ID == UUID.Zero) { m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); return false; } } else { ID = UI.UserProfile.ID; } m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); include = true; } catch (Exception e) { m_log.DebugFormat("[RADMIN] Error creating user {0} : {1}", name, e.Message); include = false; } // OK, User has been created OK, now we can install the inventory. // First retrieve the current inventory (the user may already exist) // Note that althought he inventory is retrieved, the hierarchy has // not been interpreted at all. if (include) { uic = new UICallback(); // Request the inventory iserv.GetUserInventory(ID, uic.callback); // While the inventory is being fetched, setup for appearance processing if ((mava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(ID)) == null) { mava = new AvatarAppearance(); } { AvatarWearable[] wearables = mava.Wearables; for (int i=0; i<wearables.Length; i++) { wearables[i] = new AvatarWearable(); } } // Wait for the inventory to arrive uic.GetInventory(); // We can only get dresssed if an inventory is forthcoming if (uic.OK) try { m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory", uic.folders.Count, uic.items.Count); InventoryFolderImpl cfolder = uic.root.FindFolderForType(5); // This should *never* be the case if (cfolder == null) { cfolder = new InventoryFolderImpl(); cfolder.Name = "Clothing"; cfolder.Type = 5; cfolder.Version = 1; cfolder.Owner = ID; uic.root.AddChildFolder(cfolder); // make connection iserv.AddFolder(cfolder); // store base record m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID); } // OK, now we have an inventory for the user, read in the outfits from the // default appearance XMl file. XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble"); InventoryFolderImpl efolder; string oname; UUID assetid; foreach (XmlElement outfit in outfits) { m_log.DebugFormat("[RADMIN] Loading outfit {0} for {1}", GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?")); oname = GetStringAttribute(outfit,"name",""); select = (GetStringAttribute(outfit,"default","no") == "yes"); efolder = null; // If the folder already exists, re-use it. The defaults may // change over time. Augment only. foreach (InventoryFolderImpl folder in uic.folders) { if (folder.Name == oname && folder.ParentID == cfolder.ID) { efolder = folder; break; } } // Otherwise, we must create the folder. if (efolder == null) { m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name); efolder = new InventoryFolderImpl(); efolder.ID = UUID.Random(); efolder.Name = oname; efolder.Type = 5; efolder.Version = 1; efolder.Owner = ID; cfolder.AddChildFolder(efolder); // make connection iserv.AddFolder(efolder); // store base record m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID); } // Now get the pieces that make up the outfit XmlNodeList items = outfit.GetElementsByTagName("Item"); foreach (XmlElement item in items) { assetid = UUID.Zero; XmlNodeList children = item.ChildNodes; foreach (XmlNode child in children) { switch (child.Name) { case "Permissions" : m_log.DebugFormat("[RADMIN] Permissions specified"); perms = child; break; case "Asset" : assetid = new UUID(child.InnerText); break; } } InventoryItemBase iitem = null; if ((iitem = efolder.FindAsset(assetid)) == null) { iitem = new InventoryItemBase(); iitem.ID = UUID.Random(); iitem.Name = GetStringAttribute(item,"name",""); iitem.Description = GetStringAttribute(item,"desc",""); iitem.InvType = GetIntegerAttribute(item,"invtype",-1); iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); iitem.Flags = GetUnsignedAttribute(item,"flags",0); iitem.AssetID = assetid; // associated asset iitem.Folder = efolder.ID; // Parent folder iitem.Owner = ID; // Agent ID iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff); iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); m_log.DebugFormat("[RADMIN] Adding item {0} to folder {1}", iitem.ID, efolder.ID); iserv.AddItem(iitem); } // Record whether or not the item is to be initially worn try { if (select && (GetStringAttribute(item, "wear", "false") == "true")) { mava.Wearables[iitem.Flags].ItemID = iitem.ID; mava.Wearables[iitem.Flags].AssetID = iitem.AssetID; } } catch {} } // foreach item in outfit m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); } // foreach outfit m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(ID, mava); } catch (Exception e) { m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}", name, e.Message); } else { m_log.WarnFormat("[RADMIN] Unable to retrieve inventory for {0}[{1}]", name, ID); // continue to next avatar } } // End of include } m_log.DebugFormat("[RADMIN] Default avatar loading complete"); } else { m_log.DebugFormat("[RADMIN] No default avatar information available"); return false; } } catch (Exception e) { m_log.WarnFormat("[RADMIN] Exception whilst loading default avatars ; {0}", e.Message); return false; } return true; }
public void CacheWearableData(UUID principalID, AvatarWearable cachedWearable) { }
public AvatarAppearance(AvatarAppearance appearance, bool copyWearables, bool copyBaked) { // m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); if (appearance == null) { m_serial = 0; SetDefaultWearables(); SetDefaultTexture(); SetDefaultParams(); // SetHeight(); SetSize(new Vector3(0.45f, 0.6f, 1.9f)); m_attachments = new Dictionary<int, List<AvatarAttachment>>(); return; } m_serial = appearance.Serial; if (copyWearables && (appearance.Wearables != null)) { m_wearables = new AvatarWearable[appearance.Wearables.Length]; for (int i = 0; i < appearance.Wearables.Length; i++) { m_wearables[i] = new AvatarWearable(); AvatarWearable wearable = appearance.Wearables[i]; for (int j = 0; j < wearable.Count; j++) m_wearables[i].Add(wearable[j].ItemID, wearable[j].AssetID); } } else ClearWearables(); m_texture = null; if (appearance.Texture != null) { byte[] tbytes = appearance.Texture.GetBytes(); m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); if (copyBaked && appearance.m_cacheitems != null) m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone(); else m_cacheitems = null; } m_visualparams = null; if (appearance.VisualParams != null) m_visualparams = (byte[])appearance.VisualParams.Clone(); // m_avatarHeight = appearance.m_avatarHeight; SetSize(appearance.AvatarSize); // Copy the attachment, force append mode since that ensures consistency m_attachments = new Dictionary<int, List<AvatarAttachment>>(); foreach (AvatarAttachment attachment in appearance.GetAttachments()) AppendAttachment(new AvatarAttachment(attachment)); }
// <summary> // </summary> // <param name=""></param> public AvatarData GetAvatar(UUID userID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", userID.ToString() } }; OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { OSDMap map = null; try { map = OSDParser.DeserializeJson(response["LLAppearance"].AsString()) as OSDMap; } catch { } if (map != null) { AvatarWearable[] wearables = new AvatarWearable[13]; wearables[0] = new AvatarWearable(map["ShapeItem"].AsUUID(), map["ShapeAsset"].AsUUID()); wearables[1] = new AvatarWearable(map["SkinItem"].AsUUID(), map["SkinAsset"].AsUUID()); wearables[2] = new AvatarWearable(map["HairItem"].AsUUID(), map["HairAsset"].AsUUID()); wearables[3] = new AvatarWearable(map["EyesItem"].AsUUID(), map["EyesAsset"].AsUUID()); wearables[4] = new AvatarWearable(map["ShirtItem"].AsUUID(), map["ShirtAsset"].AsUUID()); wearables[5] = new AvatarWearable(map["PantsItem"].AsUUID(), map["PantsAsset"].AsUUID()); wearables[6] = new AvatarWearable(map["ShoesItem"].AsUUID(), map["ShoesAsset"].AsUUID()); wearables[7] = new AvatarWearable(map["SocksItem"].AsUUID(), map["SocksAsset"].AsUUID()); wearables[8] = new AvatarWearable(map["JacketItem"].AsUUID(), map["JacketAsset"].AsUUID()); wearables[9] = new AvatarWearable(map["GlovesItem"].AsUUID(), map["GlovesAsset"].AsUUID()); wearables[10] = new AvatarWearable(map["UndershirtItem"].AsUUID(), map["UndershirtAsset"].AsUUID()); wearables[11] = new AvatarWearable(map["UnderpantsItem"].AsUUID(), map["UnderpantsAsset"].AsUUID()); wearables[12] = new AvatarWearable(map["SkirtItem"].AsUUID(), map["SkirtAsset"].AsUUID()); AvatarAppearance appearance = new AvatarAppearance(); appearance.Wearables = wearables; appearance.AvatarHeight = (float)map["Height"].AsReal(); AvatarData avatar = new AvatarData(appearance); // Get attachments map = null; try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; } catch { } if (map != null) { foreach (KeyValuePair<string, OSD> kvp in map) avatar.Data[kvp.Key] = kvp.Value.AsString(); } return avatar; } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ", LLAppearance is missing or invalid"); return null; } } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ": " + response["Message"].AsString()); } return null; }
/// <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 void SendWearables(AvatarWearable[] wearables, int serial) { throw new System.NotImplementedException(); }
/// <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) { // DEBUG ON m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data"); // DEBUG OFF 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["changed_grid"] != null) ChangedGrid = args["changed_grid"].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()); //This IS checked later if (args["god_level"] != null) Byte.TryParse(args["god_level"].AsString(), out GodLevel); if (args["speed"] != null) float.TryParse(args["speed"].AsString(), out Speed); else Speed = 1; if (args["draw_distance"] != null) float.TryParse(args["draw_distance"].AsString(), out DrawDistance); else DrawDistance = 0; //Reset this to fix movement... since regions are being bad about this if (Speed == 0) Speed = 1; if (args["always_run"] != null) AlwaysRun = args["always_run"].AsBoolean(); if (args["sent_initial_wearables"] != null) SentInitialWearables = args["sent_initial_wearables"].AsBoolean(); else SentInitialWearables = false; 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["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if ((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["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["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(); //} Appearance = new AvatarAppearance(AgentID); // 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); List<UUID> changed = new List<UUID>(); Appearance.SetTextureEntries(textures, out changed); } 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 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance(AgentID, (OSDMap)args["packed_appearance"]); // DEBUG ON else m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); // DEBUG OFF 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(); }
public void SetWearable(int wearableId, AvatarWearable wearable) { m_appearance.SetWearable(wearableId, wearable); m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); }
/// <summary> /// This method is called by updateAvatarAppearance once any specified model has been /// ratified, or an appropriate default value has been adopted. The intended prototype /// is known to exist, as is the target avatar. /// </summary> private void EstablishAppearance(UUID destination, UUID source) { m_log.DebugFormat("[RADMIN]: Initializing inventory for {0} from {1}", destination, source); Scene scene = m_application.SceneManager.CurrentOrFirstScene; // If the model has no associated appearance we're done. AvatarAppearance avatarAppearance = scene.AvatarService.GetAppearance(source); if (avatarAppearance == null) return; // Simple appearance copy or copy Clothing and Bodyparts folders? bool copyFolders = m_config.GetBoolean("copy_folders", false); if (!copyFolders) { // Simple copy of wearables and appearance update try { CopyWearablesAndAttachments(destination, source, avatarAppearance); scene.AvatarService.SetAppearance(destination, avatarAppearance); } catch (Exception e) { m_log.WarnFormat("[RADMIN]: Error transferring appearance for {0} : {1}", destination, e.Message); } return; } // Copy Clothing and Bodypart folders and appearance update try { Dictionary<UUID,UUID> inventoryMap = new Dictionary<UUID,UUID>(); CopyInventoryFolders(destination, source, AssetType.Clothing, inventoryMap, avatarAppearance); CopyInventoryFolders(destination, source, AssetType.Bodypart, inventoryMap, avatarAppearance); AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i=0; i<wearables.Length; i++) { if (inventoryMap.ContainsKey(wearables[i][0].ItemID)) { AvatarWearable wearable = new AvatarWearable(); wearable.Wear(inventoryMap[wearables[i][0].ItemID], wearables[i][0].AssetID); avatarAppearance.SetWearable(i, wearable); } } scene.AvatarService.SetAppearance(destination, avatarAppearance); } catch (Exception e) { m_log.WarnFormat("[RADMIN]: Error transferring appearance for {0} : {1}", destination, e.Message); } return; }
private static UUID[] WearablesToUUIDs(AvatarWearable[] aws) { // We might not pass the Wearables in all cases... // They're only needed so that persistent changes to the appearance // are preserved in the new region where the user is moving to. // But in Hypergrid we might not let this happen. int i = 0; UUID[] wears = null; if (aws != null) { wears = new UUID[aws.Length * 2]; foreach (AvatarWearable aw in aws) { if (aw != null) { wears[i++] = aw.ItemID; wears[i++] = aw.AssetID; } else { wears[i++] = UUID.Zero; wears[i++] = UUID.Zero; } } } return wears; }
/// <summary> /// This method is called if a given model avatar name can not be found. If the external /// file has already been loaded once, then control returns immediately. If not, then it /// looks for a default appearance file. This file contains XML definitions of zero or more named /// avatars, each avatar can specify zero or more "outfits". Each outfit is a collection /// of items that together, define a particular ensemble for the avatar. Each avatar should /// indicate which outfit is the default, and this outfit will be automatically worn. The /// other outfits are provided to allow "real" avatars a way to easily change their outfits. /// </summary> private bool CreateDefaultAvatars() { // Only load once if (m_defaultAvatarsLoaded) { return false; } m_log.DebugFormat("[RADMIN]: Creating default avatar entries"); m_defaultAvatarsLoaded = true; // Load processing starts here... try { string defaultAppearanceFileName = null; //m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini if (m_config != null) { defaultAppearanceFileName = m_config.GetString("default_appearance", "default_appearance.xml"); } if (File.Exists(defaultAppearanceFileName)) { XmlDocument doc = new XmlDocument(); string name = "*unknown*"; string email = "anon@anon"; uint regionXLocation = 1000; uint regionYLocation = 1000; string password = UUID.Random().ToString(); // No requirement to sign-in. UUID ID = UUID.Zero; AvatarAppearance avatarAppearance; XmlNodeList avatars; XmlNodeList assets; XmlNode perms = null; bool include = false; bool select = false; Scene scene = m_application.SceneManager.CurrentOrFirstScene; IInventoryService inventoryService = scene.InventoryService; IAssetService assetService = scene.AssetService; doc.LoadXml(File.ReadAllText(defaultAppearanceFileName)); // Load up any included assets. Duplicates will be ignored assets = doc.GetElementsByTagName("RequiredAsset"); foreach (XmlNode assetNode in assets) { AssetBase asset = new AssetBase(UUID.Random(), GetStringAttribute(assetNode, "name", ""), SByte.Parse(GetStringAttribute(assetNode, "type", "")), UUID.Zero.ToString()); asset.Description = GetStringAttribute(assetNode,"desc",""); asset.Local = Boolean.Parse(GetStringAttribute(assetNode,"local","")); asset.Temporary = Boolean.Parse(GetStringAttribute(assetNode,"temporary","")); asset.Data = Convert.FromBase64String(assetNode.InnerText); assetService.Store(asset); } avatars = doc.GetElementsByTagName("Avatar"); // The document may contain multiple avatars foreach (XmlElement avatar in avatars) { m_log.DebugFormat("[RADMIN]: Loading appearance for {0}, gender = {1}", GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?")); // Create the user identified by the avatar entry try { // Only the name value is mandatory name = GetStringAttribute(avatar,"name",name); email = GetStringAttribute(avatar,"email",email); regionXLocation = GetUnsignedAttribute(avatar,"regx",regionXLocation); regionYLocation = GetUnsignedAttribute(avatar,"regy",regionYLocation); password = GetStringAttribute(avatar,"password",password); string[] names = name.Split(); UUID scopeID = scene.RegionInfo.ScopeID; UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, names[0], names[1]); if (null == account) { account = CreateUser(scopeID, names[0], names[1], password, email); if (null == account) { m_log.ErrorFormat("[RADMIN]: Avatar {0} {1} was not created", names[0], names[1]); return false; } } // Set home position GridRegion home = scene.GridService.GetRegionByPosition(scopeID, (int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize)); if (null == home) { m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]); } else { scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, names[0], names[1]); } ID = account.PrincipalID; m_log.DebugFormat("[RADMIN]: User {0}[{1}] created or retrieved", name, ID); include = true; } catch (Exception e) { m_log.DebugFormat("[RADMIN]: Error creating user {0} : {1}", name, e.Message); include = false; } // OK, User has been created OK, now we can install the inventory. // First retrieve the current inventory (the user may already exist) // Note that althought he inventory is retrieved, the hierarchy has // not been interpreted at all. if (include) { // Setup for appearance processing avatarAppearance = scene.AvatarService.GetAppearance(ID); if (avatarAppearance == null) avatarAppearance = new AvatarAppearance(); AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i=0; i<wearables.Length; i++) { wearables[i] = new AvatarWearable(); } try { // m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory", // uic.folders.Count, uic.items.Count); InventoryFolderBase clothingFolder = inventoryService.GetFolderForType(ID, AssetType.Clothing); // This should *never* be the case if (clothingFolder == null || clothingFolder.Type != (short)AssetType.Clothing) { clothingFolder = new InventoryFolderBase(); clothingFolder.ID = UUID.Random(); clothingFolder.Name = "Clothing"; clothingFolder.Owner = ID; clothingFolder.Type = (short)AssetType.Clothing; clothingFolder.ParentID = inventoryService.GetRootFolder(ID).ID; clothingFolder.Version = 1; inventoryService.AddFolder(clothingFolder); // store base record m_log.ErrorFormat("[RADMIN]: Created clothing folder for {0}/{1}", name, ID); } // OK, now we have an inventory for the user, read in the outfits from the // default appearance XMl file. XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble"); InventoryFolderBase extraFolder; string outfitName; UUID assetid; foreach (XmlElement outfit in outfits) { m_log.DebugFormat("[RADMIN]: Loading outfit {0} for {1}", GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?")); outfitName = GetStringAttribute(outfit,"name",""); select = (GetStringAttribute(outfit,"default","no") == "yes"); // If the folder already exists, re-use it. The defaults may // change over time. Augment only. List<InventoryFolderBase> folders = inventoryService.GetFolderContent(ID, clothingFolder.ID).Folders; extraFolder = null; foreach (InventoryFolderBase folder in folders) { if (folder.Name == outfitName) { extraFolder = folder; break; } } // Otherwise, we must create the folder. if (extraFolder == null) { m_log.DebugFormat("[RADMIN]: Creating outfit folder {0} for {1}", outfitName, name); extraFolder = new InventoryFolderBase(); extraFolder.ID = UUID.Random(); extraFolder.Name = outfitName; extraFolder.Owner = ID; extraFolder.Type = (short)AssetType.Clothing; extraFolder.Version = 1; extraFolder.ParentID = clothingFolder.ID; inventoryService.AddFolder(extraFolder); m_log.DebugFormat("[RADMIN]: Adding outfile folder {0} to folder {1}", extraFolder.ID, clothingFolder.ID); } // Now get the pieces that make up the outfit XmlNodeList items = outfit.GetElementsByTagName("Item"); foreach (XmlElement item in items) { assetid = UUID.Zero; XmlNodeList children = item.ChildNodes; foreach (XmlNode child in children) { switch (child.Name) { case "Permissions" : m_log.DebugFormat("[RADMIN]: Permissions specified"); perms = child; break; case "Asset" : assetid = new UUID(child.InnerText); break; } } InventoryItemBase inventoryItem = null; // Check if asset is in inventory already inventoryItem = null; List<InventoryItemBase> inventoryItems = inventoryService.GetFolderContent(ID, extraFolder.ID).Items; foreach (InventoryItemBase listItem in inventoryItems) { if (listItem.AssetID == assetid) { inventoryItem = listItem; break; } } // Create inventory item if (inventoryItem == null) { inventoryItem = new InventoryItemBase(UUID.Random(), ID); inventoryItem.Name = GetStringAttribute(item,"name",""); inventoryItem.Description = GetStringAttribute(item,"desc",""); inventoryItem.InvType = GetIntegerAttribute(item,"invtype",-1); inventoryItem.CreatorId = GetStringAttribute(item,"creatorid",""); inventoryItem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid",""); inventoryItem.CreatorData = GetStringAttribute(item, "creatordata", ""); inventoryItem.NextPermissions = GetUnsignedAttribute(perms, "next", 0x7fffffff); inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); inventoryItem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); inventoryItem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); inventoryItem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); inventoryItem.AssetType = GetIntegerAttribute(item,"assettype",-1); inventoryItem.AssetID = assetid; // associated asset inventoryItem.GroupID = (UUID)GetStringAttribute(item,"groupid",""); inventoryItem.GroupOwned = (GetStringAttribute(item,"groupowned","false") == "true"); inventoryItem.SalePrice = GetIntegerAttribute(item,"saleprice",0); inventoryItem.SaleType = (byte)GetIntegerAttribute(item,"saletype",0); inventoryItem.Flags = GetUnsignedAttribute(item,"flags",0); inventoryItem.CreationDate = GetIntegerAttribute(item,"creationdate",Util.UnixTimeSinceEpoch()); inventoryItem.Folder = extraFolder.ID; // Parent folder m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(inventoryItem); m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", inventoryItem.ID, extraFolder.ID); } // Attach item, if attachpoint is specified int attachpoint = GetIntegerAttribute(item,"attachpoint",0); if (attachpoint != 0) { avatarAppearance.SetAttachment(attachpoint, inventoryItem.ID, inventoryItem.AssetID); m_log.DebugFormat("[RADMIN]: Attached {0}", inventoryItem.ID); } // Record whether or not the item is to be initially worn try { if (select && (GetStringAttribute(item, "wear", "false") == "true")) { avatarAppearance.Wearables[inventoryItem.Flags].Wear(inventoryItem.ID, inventoryItem.AssetID); } } catch (Exception e) { m_log.WarnFormat("[RADMIN]: Error wearing item {0} : {1}", inventoryItem.ID, e.Message); } } // foreach item in outfit m_log.DebugFormat("[RADMIN]: Outfit {0} load completed", outfitName); } // foreach outfit m_log.DebugFormat("[RADMIN]: Inventory update complete for {0}", name); scene.AvatarService.SetAppearance(ID, avatarAppearance); } catch (Exception e) { m_log.WarnFormat("[RADMIN]: Inventory processing incomplete for user {0} : {1}", name, e.Message); } } // End of include } m_log.DebugFormat("[RADMIN]: Default avatar loading complete"); } else { m_log.DebugFormat("[RADMIN]: No default avatar information available"); return false; } } catch (Exception e) { m_log.WarnFormat("[RADMIN]: Exception whilst loading default avatars ; {0}", e.Message); return false; } return true; }
public void SetWearable(int wearableId, AvatarWearable wearable) { m_appearance.SetWearable(wearableId, wearable); AvatarData adata = new AvatarData(m_appearance); m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); }
public void ClearWearables() { m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) m_wearables[i] = new AvatarWearable(); }
public void CopyFrom(AgentData cAgent) { m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; m_pos = cAgent.Position; m_velocity = cAgent.Velocity; m_CameraCenter = cAgent.Center; //m_avHeight = cAgent.Size.Z; m_CameraAtAxis = cAgent.AtAxis; m_CameraLeftAxis = cAgent.LeftAxis; m_CameraUpAxis = cAgent.UpAxis; m_DrawDistance = cAgent.Far; if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgent.Throttles); m_headrotation = cAgent.HeadRotation; m_bodyRot = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) m_godLevel = cAgent.GodLevel; m_setAlwaysRun = cAgent.AlwaysRun; uint i = 0; try { if (cAgent.Wearables == null) cAgent.Wearables = new UUID[0]; AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; for (uint n = 0; n < cAgent.Wearables.Length; n += 2) { UUID itemId = cAgent.Wearables[n]; UUID assetId = cAgent.Wearables[n + 1]; wears[i++] = new AvatarWearable(itemId, assetId); } m_appearance.Wearables = wears; Primitive.TextureEntry te; if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); else te = AvatarAppearance.GetDefaultTexture(); if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); } catch (Exception e) { m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); } // Attachments try { if (cAgent.Attachments != null) { foreach (AttachmentData att in cAgent.Attachments) { m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); } } } catch { } // Animations try { Animator.ResetAnimations(); Animator.Animations.FromArray(cAgent.Anims); } catch { } //cAgent.GroupID = ?? //Groups??? }
/// <summary> /// Unpack and OSDMap and initialize the appearance /// from it /// </summary> public void Unpack(OSDMap data) { if ((data != null) && (data["serial"] != null)) m_serial = data["serial"].AsInteger(); if ((data != null) && (data["height"] != null)) m_avatarHeight = (float)data["height"].AsReal(); try { // Wearables SetDefaultWearables(); if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(data["wearables"]); for (int i = 0; i < wears.Count; i++) m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); } // Avatar Textures SetDefaultTexture(); if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array) { OSDArray textures = (OSDArray)(data["textures"]); for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) { UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; if (textures[i] != null) textureID = textures[i].AsUUID(); m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); } } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); } // Visual Parameters SetDefaultParams(); if ((data != null) && (data["visualparams"] != null)) { if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array)) m_visualparams = data["visualparams"].AsBinary(); } else { m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters"); } // Attachments m_attachments = new Dictionary<int, List<AvatarAttachment>>(); if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(data["attachments"]); for (int i = 0; i < attachs.Count; i++) AppendAttachment(new AvatarAttachment((OSDMap)attachs[i])); } } catch (Exception e) { m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.ToString(), e.StackTrace); } }
public AvatarWearable(AvatarWearable wearable) { WearableType = wearable.WearableType; ItemID = wearable.ItemID; AssetID = wearable.AssetID; }