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); } }
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; }
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 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()); } }
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; }
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); }