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; }
void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (transfer.Success && asset.AssetType == AssetType.Landmark) { decodedLandmark = (AssetLandmark)asset; decodedLandmark.Decode(); localPosition = decodedLandmark.Position; client.Grid.RequestRegionHandle(decodedLandmark.RegionID); } }
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; }
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 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 bool UploadAssetData(bool storeLocal) { if (IsLocalScene) { ReplaceAll(); RezRequested = true; NewID = OldID; _NewItem = OldItem; return true; } if (CogbotHelpers.IsNullOrZero(NewID)) { if (UseUploadKnown) { AssetUploaded.Reset(); if (assetType == AssetType.Notecard) { Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID, Description, assetType, UUID.Zero, OpenMetaverse.InventoryType.Notecard, PermissionMask.All, UpdateInvItem); } else if (assetType == AssetType.Gesture) { Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID, Description, assetType, UUID.Zero, OpenMetaverse.InventoryType.Gesture, PermissionMask.All, UpdateInvItem); // (gesture.Sequence) } else if (assetType == AssetType.LSLText) { Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID, Description, assetType, UUID.Zero, OpenMetaverse.InventoryType.LSL, PermissionMask.All, UpdateInvItem); } else if (assetType == AssetType.Landmark) { var decodeME = new AssetLandmark(UUID.Zero, AssetData); decodeME.Decode(); byte[] bytes = AssetData; Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID, "RegionID:" + decodeME.RegionID + ",Postion" + decodeME.Position + "," + DateTime.Now, assetType, UUID.Zero, OpenMetaverse.InventoryType.Landmark, PermissionMask.All, UpdateInvItem); } else if (assetType == AssetType.CallingCard) { var decodeME = new AssetCallingCard(UUID.Zero, AssetData); decodeME.Decode(); byte[] bytes = AssetData; Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID, "AvatarID:" + decodeME.AvatarID + "," + DateTime.Now, assetType, UUID.Zero, OpenMetaverse.InventoryType.CallingCard, PermissionMask.All, UpdateInvItem); } else { Inventory.RequestCreateItemFromAsset(AssetData, "" + OldID, Description, assetType, inventoryType, GetAssetUploadsFolder(), Permissions.FullPermissions, InvItemCreated); } if (!AssetUploaded.WaitOne(10000)) { return false; } return true; } NewID = UUID.Combine(OldID, Importing.Client.Self.SecureSessionID); NewUUID2OBJECT[NewID] = this; Importing.Client.Assets.RequestUploadKnown(NewID, assetType, AssetData, storeLocal, OldID); RezRequested = true; } return true; }