/// <summary> /// Update the local Avatar Appearance information based on the contents of the assets as defined in the cached wearable data info. /// </summary> protected void GetAvatarAppearanceInfoFromWearableAssets() { // Make sure we have some Wearable Data to start with. if (AgentWearablesSignal.WaitOne(1000, false) == false) { Client.Log("Cannot get Visual Param data from wearable assets. AgentWearablesSignal not set.", Helpers.LogLevel.Error); return; } // Clear current look AgentTextureEntry = new LLObject.TextureEntry("C228D1CF4B5D4BA884F4899A0796AA97"); // if this isn't valid, blame JH ;-) AgentAppearanceParams = new SerializableDictionary <int, float>(); // Build params and texture entries from wearable data foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in AgentWearablesData) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AssetRequestDownload request = Client.Assets.RequestInventoryAsset(wearableAsset.AssetID, wearableAsset.Type); if (request.Wait(AssetManager.DefaultTimeout) != AssetRequestDownload.RequestStatus.Success) { Client.Log("Asset (" + wearableAsset.AssetID.ToStringHyphenated() + ") unavailable (" + request.StatusMsg + ")", Helpers.LogLevel.Error); } else { wearableAsset.SetAssetData(request.GetAssetData()); } if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } UpdateAgentTextureEntryAndAppearanceParams(wearableAsset); } UpdateAgentTextureEntryOrder(); }
override internal void SetAssetData(byte[] assetData) { // Must reference all variables by internal _private names, so as not to trigger accessor code if (_Asset == null) { if (_AssetID != null) { if (_Type == (sbyte)WearableType.Clothing) { _Asset = new AssetWearable_Clothing(_AssetID, assetData); } else { _Asset = new AssetWearable_Body(_AssetID, assetData); } } else { if (_Type == (sbyte)WearableType.Clothing) { _Asset = new AssetWearable_Clothing(LLUUID.Random(), assetData); } else { _Asset = new AssetWearable_Body(LLUUID.Random(), assetData); } _AssetID = _Asset.AssetID; } } else { _Asset.SetAssetData(assetData); } }
private void AgentWearablesUpdateCallbackHandler(Packet packet, Simulator simulator) { AgentWearablesUpdatePacket wearablesPacket = (AgentWearablesUpdatePacket)packet; AgentWearablesData = wearablesPacket.WearableData; AgentWearablesSignal.Set(); // Grab access mutex... WearableCacheQueueMutex.WaitOne(); // Queue download of wearables foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in AgentWearablesData) { // Don't try to download if AssetID is zero if (wdb.AssetID == LLUUID.Zero) { continue; } // Don't try to download, if it's already cached. if (WearableCache.ContainsKey(wdb.AssetID)) { AssetWearable aw = WearableCache[wdb.AssetID]; if (aw._AssetData != null) { continue; } } // Don't try to download, if it's already in the download queue lock (WearableAssetQueue) { if (WearableAssetQueue.Contains(wdb.AssetID)) { continue; } } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } WearableCache[wdb.AssetID] = wearableAsset; lock (WearableAssetQueue) { if (!WearableAssetQueue.Contains(wdb.AssetID)) { WearableAssetQueue.Add(wdb.AssetID); LogWearableAssetQueueActivity("Added wearable asset to download queue: " + wearableAsset.GetType().Name + " : " + wdb.AssetID); } } } RequestNextQueuedWearableAsset(); WearableCacheQueueMutex.ReleaseMutex(); }
/// <summary> /// Update the local Avatar Appearance information based on the contents of the assets as defined in the cached wearable data info. /// </summary> protected void GetAvatarAppearanceInfoFromWearableAssets() { // Make sure we have some Wearable Data to start with. if (AgentWearablesSignal.WaitOne(1000, false) == false) { Client.Log("Cannot get Visual Param data from wearable assets. AgentWearablesSignal not set.", Helpers.LogLevel.Error); return; } // Clear current look AgentTextureEntry = new LLObject.TextureEntry("C228D1CF4B5D4BA884F4899A0796AA97"); // if this isn't valid, blame JH ;-) AgentAppearanceParams = new SerializableDictionary<int, float>(); // Build params and texture entries from wearable data foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in AgentWearablesData) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AssetRequestDownload request = Client.Assets.RequestInventoryAsset(wearableAsset.AssetID, wearableAsset.Type); if (request.Wait(AssetManager.DefaultTimeout) != AssetRequestDownload.RequestStatus.Success) { Client.Log("Asset (" + wearableAsset.AssetID.ToStringHyphenated() + ") unavailable (" + request.StatusMsg + ")", Helpers.LogLevel.Error); } else { wearableAsset.SetAssetData(request.GetAssetData()); } if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } UpdateAgentTextureEntryAndAppearanceParams(wearableAsset); } UpdateAgentTextureEntryOrder(); }
public void GetAvatarAppearanceInfoFromWearableAssets() { AgentWearablesUpdatePacket.WearableDataBlock[] wdbs = GetWearables(); foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in wdbs) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AManager.GetInventoryAsset(wearableAsset); if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } try { foreach (KeyValuePair<uint, LLUUID> texture in wearableAsset.Textures) { AgentTextureEntry.CreateFace(texture.Key).TextureID = texture.Value; } foreach (KeyValuePair<uint, float> kvp in wearableAsset.Parameters) { AgentAppearanceParams[kvp.Key] = kvp.Value; } } catch (Exception e) { Client.Log("ItemID: " + wdb.ItemID + Environment.NewLine + "WearableType: " + wdb.WearableType + Environment.NewLine + "Retrieving as type: " + wearableAsset.Type + Environment.NewLine + e.ToString() + Environment.NewLine + wearableAsset.AssetDataToString(), Helpers.LogLevel.Error); } } // Correct the order of the textures foreach (uint faceid in AgentTextureEntry.FaceTextures.Keys) { switch (faceid) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 12: case 13: case 14: case 15: case 16: case 17: case 18: break; default: Client.Log("Unknown order for FaceID: " + faceid + Environment.NewLine + "Your wearables define a face that we don't know the order of. Please " + "capture a AgentSetAppearance packet for your current outfit and submit to " + "[email protected], thanks!", Helpers.LogLevel.Info); break; } } //Re-order texture faces to match Linden Labs internal data structure. TextureEntry te2 = new TextureEntry(AgentTextureEntry.DefaultTexture.TextureID); te2.CreateFace(18).TextureID = AgentTextureEntry.GetFace(18).TextureID; te2.CreateFace(17).TextureID = AgentTextureEntry.GetFace(17).TextureID; te2.CreateFace(16).TextureID = AgentTextureEntry.GetFace(16).TextureID; te2.CreateFace(15).TextureID = AgentTextureEntry.GetFace(15).TextureID; te2.CreateFace(14).TextureID = AgentTextureEntry.GetFace(14).TextureID; te2.CreateFace(13).TextureID = AgentTextureEntry.GetFace(13).TextureID; te2.CreateFace(12).TextureID = AgentTextureEntry.GetFace(12).TextureID; // I wonder if shoes are somewhere in here? te2.CreateFace(7).TextureID = AgentTextureEntry.GetFace(7).TextureID; te2.CreateFace(6).TextureID = AgentTextureEntry.GetFace(6).TextureID; te2.CreateFace(5).TextureID = AgentTextureEntry.GetFace(5).TextureID; te2.CreateFace(4).TextureID = AgentTextureEntry.GetFace(4).TextureID; te2.CreateFace(3).TextureID = AgentTextureEntry.GetFace(3).TextureID; te2.CreateFace(2).TextureID = AgentTextureEntry.GetFace(2).TextureID; te2.CreateFace(1).TextureID = AgentTextureEntry.GetFace(1).TextureID; te2.CreateFace(0).TextureID = AgentTextureEntry.GetFace(0).TextureID; AgentTextureEntry = te2; }
public void GetAvatarAppearanceInfoFromWearableAssets() { AgentWearablesUpdatePacket.WearableDataBlock[] wdbs = GetWearables(); foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in wdbs) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AManager.GetInventoryAsset(wearableAsset); if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } try { foreach (KeyValuePair <uint, LLUUID> texture in wearableAsset.Textures) { AgentTextureEntry.CreateFace(texture.Key).TextureID = texture.Value; } foreach (KeyValuePair <uint, float> kvp in wearableAsset.Parameters) { AgentAppearanceParams[kvp.Key] = kvp.Value; } } catch (Exception e) { Client.Log("ItemID: " + wdb.ItemID + Environment.NewLine + "WearableType: " + wdb.WearableType + Environment.NewLine + "Retrieving as type: " + wearableAsset.Type + Environment.NewLine + e.ToString() + Environment.NewLine + wearableAsset.AssetDataToString(), Helpers.LogLevel.Error); } } // Correct the order of the textures foreach (uint faceid in AgentTextureEntry.FaceTextures.Keys) { switch (faceid) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 12: case 13: case 14: case 15: case 16: case 17: case 18: break; default: Client.Log("Unknown order for FaceID: " + faceid + Environment.NewLine + "Your wearables define a face that we don't know the order of. Please " + "capture a AgentSetAppearance packet for your current outfit and submit to " + "[email protected], thanks!", Helpers.LogLevel.Info); break; } } //Re-order texture faces to match Linden Labs internal data structure. TextureEntry te2 = new TextureEntry(AgentTextureEntry.DefaultTexture.TextureID); te2.CreateFace(18).TextureID = AgentTextureEntry.GetFace(18).TextureID; te2.CreateFace(17).TextureID = AgentTextureEntry.GetFace(17).TextureID; te2.CreateFace(16).TextureID = AgentTextureEntry.GetFace(16).TextureID; te2.CreateFace(15).TextureID = AgentTextureEntry.GetFace(15).TextureID; te2.CreateFace(14).TextureID = AgentTextureEntry.GetFace(14).TextureID; te2.CreateFace(13).TextureID = AgentTextureEntry.GetFace(13).TextureID; te2.CreateFace(12).TextureID = AgentTextureEntry.GetFace(12).TextureID; // I wonder if shoes are somewhere in here? te2.CreateFace(7).TextureID = AgentTextureEntry.GetFace(7).TextureID; te2.CreateFace(6).TextureID = AgentTextureEntry.GetFace(6).TextureID; te2.CreateFace(5).TextureID = AgentTextureEntry.GetFace(5).TextureID; te2.CreateFace(4).TextureID = AgentTextureEntry.GetFace(4).TextureID; te2.CreateFace(3).TextureID = AgentTextureEntry.GetFace(3).TextureID; te2.CreateFace(2).TextureID = AgentTextureEntry.GetFace(2).TextureID; te2.CreateFace(1).TextureID = AgentTextureEntry.GetFace(1).TextureID; te2.CreateFace(0).TextureID = AgentTextureEntry.GetFace(0).TextureID; AgentTextureEntry = te2; }