/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="assetBase"></param> private void RecordWearableAssetUuids(AssetBase assetBase) { AssetWearable wearableAsset = new AssetBodypart(assetBase.FullID, assetBase.Data); wearableAsset.Decode(); foreach (UUID uuid in wearableAsset.Textures.Values) { GatheredUuids[uuid] = (sbyte)AssetType.Texture; } }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="assetBase"></param> private void RecordWearableAssetUuids(AssetBase assetBase) { //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart(assetBase.FullID, assetBase.Data); wearableAsset.Decode(); //m_log.DebugFormat( // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) { GatheredUuids[uuid] = (sbyte)AssetType.Texture; } }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="wearableAssetUuid"></param> /// <param name="assetUuids">Dictionary in which to record the references</param> protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary <UUID, int> assetUuids) { AssetBase assetBase = GetAsset(wearableAssetUuid); //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart(wearableAssetUuid, assetBase.Data); wearableAsset.Decode(); //m_log.DebugFormat( // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) { //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); assetUuids[uuid] = 1; } }
void LoadAssets(string path) { try { string[] textures = Directory.GetFiles(path, "*.jp2", SearchOption.TopDirectoryOnly); string[] clothing = Directory.GetFiles(path, "*.clothing", SearchOption.TopDirectoryOnly); string[] bodyparts = Directory.GetFiles(path, "*.bodypart", SearchOption.TopDirectoryOnly); string[] sounds = Directory.GetFiles(path, "*.ogg", SearchOption.TopDirectoryOnly); for (int i = 0; i < textures.Length; i++) { UUID assetID = ParseUUIDFromFilename(textures[i]); Asset asset = new AssetTexture(assetID, File.ReadAllBytes(textures[i])); asset.Temporary = true; StoreAsset(asset); } for (int i = 0; i < clothing.Length; i++) { UUID assetID = ParseUUIDFromFilename(clothing[i]); Asset asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); asset.Temporary = true; StoreAsset(asset); } for (int i = 0; i < bodyparts.Length; i++) { UUID assetID = ParseUUIDFromFilename(bodyparts[i]); Asset asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); asset.Temporary = true; StoreAsset(asset); } for (int i = 0; i < sounds.Length; i++) { UUID assetID = ParseUUIDFromFilename(sounds[i]); Asset asset = new AssetSound(assetID, File.ReadAllBytes(sounds[i])); asset.Temporary = true; StoreAsset(asset); } } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Warning, ex); } }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="wearableAssetUuid"></param> /// <param name="assetUuids">Dictionary in which to record the references</param> private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary <UUID, AssetType> assetUuids) { AssetBase assetBase = GetAsset(wearableAssetUuid); if (null != assetBase) { //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart(wearableAssetUuid, assetBase.Data); wearableAsset.Decode(); //m_log.DebugFormat( // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) { assetUuids[uuid] = AssetType.Texture; } } }
private Asset CreateAssetWrapper(AssetType type) { Asset asset; switch (type) { case AssetType.Notecard: asset = new AssetNotecard(); break; case AssetType.LSLText: asset = new AssetScriptText(); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(); break; case AssetType.Texture: asset = new AssetTexture(); break; case AssetType.Object: asset = new AssetPrim(); break; case AssetType.Clothing: asset = new AssetClothing(); break; case AssetType.Bodypart: asset = new AssetBodypart(); break; case AssetType.Animation: asset = new AssetAnimation(); break; case AssetType.Sound: asset = new AssetSound(); break; case AssetType.Landmark: asset = new AssetLandmark(); break; case AssetType.Gesture: asset = new AssetGesture(); break; default: Logger.Log("Unimplemented asset type: " + type, Helpers.LogLevel.Error, Client); return null; } return asset; }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="wearableAssetUuid"></param> /// <param name="assetUuids">Dictionary in which to record the references</param> private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids) { AssetBase assetBase = GetAsset(wearableAssetUuid); if (null != assetBase) { //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart(wearableAssetUuid, assetBase.Data); wearableAsset.Decode(); //m_log.DebugFormat( // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) { assetUuids[uuid] = (sbyte)AssetType.Texture; } } }
public void MakeDefaultAppearance(string wear) { try { if (wear == "yes") { //TODO: Implement random outfit picking m_log.DebugFormat("Picks a random outfit. Not yet implemented."); } else if (wear != "save") { saveDir = "MyAppearance/" + wear; } saveDir = saveDir + "/"; string[] clothing = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly); string[] bodyparts = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly); InventoryFolder clothfolder = FindClothingFolder(); UUID transid = UUID.Random(); List <InventoryBase> listwearables = new List <InventoryBase>(); for (int i = 0; i < clothing.Length; i++) { UUID assetID = UUID.Random(); AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); asset.Decode(); asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(clothing[i]); asset.Encode(); transid = Client.Assets.RequestUpload(asset, true); Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask) PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) { listwearables.Add(item); } else { m_log.WarnFormat("Failed to create item {0}", item.Name); } } ); } for (int i = 0; i < bodyparts.Length; i++) { UUID assetID = UUID.Random(); AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); asset.Decode(); asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(bodyparts[i]); asset.Encode(); transid = Client.Assets.RequestUpload(asset, true); Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask) PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) { listwearables.Add(item); } else { m_log.WarnFormat("Failed to create item {0}", item.Name); } } ); } Thread.Sleep(1000); if (listwearables == null || listwearables.Count == 0) { m_log.DebugFormat("Nothing to send on this folder!"); } else { m_log.DebugFormat("Sending {0} wearables...", listwearables.Count); Client.Appearance.WearOutfit(listwearables, false); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private static bool LoadAsset(string assetPath, byte[] data, AssetLoadedCallback assetCallback, long bytesRead, long totalBytes) { // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); if (i == -1) { Logger.Log(String.Format( "[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning); return false; } string extension = filename.Substring(i); UUID uuid; UUID.TryParse(filename.Remove(filename.Length - extension.Length), out uuid); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; Asset asset = null; switch (assetType) { case AssetType.Animation: asset = new AssetAnimation(uuid, data); break; case AssetType.Bodypart: asset = new AssetBodypart(uuid, data); break; case AssetType.Clothing: asset = new AssetClothing(uuid, data); break; case AssetType.Gesture: asset = new AssetGesture(uuid, data); break; case AssetType.Landmark: asset = new AssetLandmark(uuid, data); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(uuid, data); break; case AssetType.LSLText: asset = new AssetScriptText(uuid, data); break; case AssetType.Notecard: asset = new AssetNotecard(uuid, data); break; case AssetType.Object: asset = new AssetPrim(uuid, data); break; case AssetType.Sound: asset = new AssetSound(uuid, data); break; case AssetType.Texture: asset = new AssetTexture(uuid, data); break; default: Logger.Log("[OarFile] Unhandled asset type " + assetType, Helpers.LogLevel.Error); break; } if (asset != null) { assetCallback(asset, bytesRead, totalBytes); return true; } } Logger.Log("[OarFile] Failed to load asset", Helpers.LogLevel.Warning); return false; }
public void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (asset == null && transfer != null) { Hashtable hash = new Hashtable(); hash.Add("MessageType", "AssetReceived"); hash.Add("Success", false); if (transfer != null) { hash.Add("TransferID", transfer.ID); hash.Add("AssetID", transfer.AssetID); hash.Add("Error", transfer.Status.ToString()); hash.Add("AssetType", transfer.AssetType); } enqueue(hash); return; } if (transfer == null) { Hashtable hash = new Hashtable(); hash.Add("MessageType", "NullTransfer"); enqueue(hash); return; } try { Hashtable hash = new Hashtable(); hash.Add("MessageType", "AssetReceived"); hash.Add("Success", transfer.Success); if (!transfer.Success) { hash.Add("AssetData", "Could not download asset: " + transfer.Status.ToString()); } else { switch (asset.AssetType) { case AssetType.Notecard: case AssetType.LSLText: hash.Add("AssetData", Helpers.FieldToUTF8String(asset.AssetData)); break; case AssetType.Bodypart: { AssetBodypart part = (AssetBodypart)asset; hash.Add("Creator", part.Creator); hash.Add("Description", part.Description); hash.Add("Textures", part.Textures); hash.Add("Params", part.Params); hash.Add("Permissions", part.Permissions); hash.Add("Owner", part.Owner); } break; } } hash.Add("AssetType", transfer.AssetType); hash.Add("AssetID", transfer.AssetID); hash.Add("TransferID", transfer.ID); enqueue(hash); } catch { } }
public void MakeDefaultAppearance(string wear) { try { if (wear == "yes") { //TODO: Implement random outfit picking m_log.DebugFormat("Picks a random outfit. Not yet implemented."); } else if (wear != "save") saveDir = "MyAppearance/" + wear; saveDir = saveDir + "/"; string[] clothing = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly); string[] bodyparts = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly); InventoryFolder clothfolder = FindClothingFolder(); UUID transid = UUID.Random(); List<InventoryBase> listwearables = new List<InventoryBase>(); for (int i = 0; i < clothing.Length; i++) { UUID assetID = UUID.Random(); AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); asset.Decode(); asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(clothing[i]); asset.Encode(); transid = Client.Assets.RequestUpload(asset,true); Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask)PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) { listwearables.Add(item); } else { m_log.WarnFormat("Failed to create item {0}", item.Name); } } ); } for (int i = 0; i < bodyparts.Length; i++) { UUID assetID = UUID.Random(); AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); asset.Decode(); asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(bodyparts[i]); asset.Encode(); transid = Client.Assets.RequestUpload(asset,true); Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask)PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) { listwearables.Add(item); } else { m_log.WarnFormat("Failed to create item {0}", item.Name); } } ); } Thread.Sleep(1000); if (listwearables == null || listwearables.Count == 0) { m_log.DebugFormat("Nothing to send on this folder!"); } else { m_log.DebugFormat("Sending {0} wearables...", listwearables.Count); Client.Appearance.WearOutfit(listwearables, false); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="wearableAssetUuid"></param> /// <param name="assetUuids">Dictionary in which to record the references</param> protected void GetWearableAssetUuids (UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) { AssetBase assetBase = GetAsset (wearableAssetUuid); if (null != assetBase) { //MainConsole.Instance.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart (wearableAssetUuid, assetBase.Data); wearableAsset.Decode (); //MainConsole.Instance.DebugFormat( // "[Archiver]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) { assetUuids [uuid] = AssetType.Texture; } } }
public static Asset CreateAssetWrapper(AssetType type, UUID uuid, byte[] data) { Asset asset; switch (type) { case AssetType.Animation: asset = new AssetAnimation(uuid, data); break; case AssetType.Gesture: asset = new AssetGesture(uuid, data); break; case AssetType.Landmark: asset = new AssetLandmark(uuid, data); break; case AssetType.Bodypart: asset = new AssetBodypart(uuid, data); break; case AssetType.Clothing: asset = new AssetClothing(uuid, data); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(uuid, data); break; case AssetType.LSLText: asset = new AssetScriptText(uuid, data); break; case AssetType.Notecard: asset = new AssetNotecard(uuid, data); break; case AssetType.Sound: asset = new AssetSound(uuid, data); break; case AssetType.Texture: asset = new AssetTexture(uuid, data); break; #if COGBOT_LIBOMV case AssetType.CallingCard: asset = new AssetCallingCard(uuid, data); break; #endif default: #if COGBOT_LIBOMV asset = new AssetMutable(type, uuid, data); Logger.Log("[OarFile] Not Implemented asset type " + type, Helpers.LogLevel.Error); #else throw new NotImplementedException("Unimplemented asset type: " + type); #endif break; } return asset; }
/// <summary> /// Record the uuids referenced by the given wearable asset /// </summary> /// <param name="assetBase"></param> private void RecordWearableAssetUuids(AssetBase assetBase) { //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); AssetWearable wearableAsset = new AssetBodypart(assetBase.FullID, assetBase.Data); wearableAsset.Decode(); //m_log.DebugFormat( // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); foreach (UUID uuid in wearableAsset.Textures.Values) GatheredUuids[uuid] = (sbyte)AssetType.Texture; }
public static Asset CreateAssetWrapper(AssetType type, UUID uuid, byte[] data) { Asset asset; switch (type) { case AssetType.Animation: asset = new AssetAnimation(uuid, data); break; case AssetType.Gesture: asset = new AssetGesture(uuid, data); break; case AssetType.Landmark: asset = new AssetLandmark(uuid, data); break; case AssetType.Bodypart: asset = new AssetBodypart(uuid, data); break; case AssetType.Clothing: asset = new AssetClothing(uuid, data); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(uuid, data); break; case AssetType.LSLText: asset = new AssetScriptText(uuid, data); break; case AssetType.Notecard: asset = new AssetNotecard(uuid, data); break; case AssetType.Sound: asset = new AssetSound(uuid, data); break; case AssetType.Texture: asset = new AssetTexture(uuid, data); break; #if COGBOT_LIBOMV case AssetType.CallingCard: asset = new AssetCallingCard(uuid, data); break; #endif default: #if COGBOT_LIBOMV asset = new AssetMutable(type, uuid, data); Logger.Log("[OarFile] Not Implemented asset type " + type, Helpers.LogLevel.Error); #else throw new NotImplementedException("Unimplemented asset type: " + type); #endif break; } return(asset); }