Example #1
0
        public void T010_StoreSimpleAsset()
        {
            AssetBase a1 = new AssetBase(uuid1, "asset one");
            AssetBase a2 = new AssetBase(uuid2, "asset two");
            AssetBase a3 = new AssetBase(uuid3, "asset three");
            a1.Data = asset1;
            a2.Data = asset1;
            a3.Data = asset1;

            db.CreateAsset(a1);
            db.CreateAsset(a2);
            db.CreateAsset(a3);

            AssetBase a1a = db.FetchAsset(uuid1);
            Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))");
            Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");

            AssetBase a2a = db.FetchAsset(uuid2);
            Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))");
            Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");

            AssetBase a3a = db.FetchAsset(uuid3);
            Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))");
            Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))");
        }
Example #2
0
 public AssetLandmark(AssetBase a)
     : base(a.FullID, a.Name, a.Type)
 {
     Data = a.Data;
     Description = a.Description;
     InternData();
 }
Example #3
0
 public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile)
 {
     m_transactions = transactions;
     m_Scene = scene;
     m_asset = new AssetBase() { FullID = assetID };
     m_dumpAssetToFile = dumpAssetToFile;
 }
Example #4
0
        public void TestWriteAndRetrieveAssets()
        {
            if (!_runTests) return;

            AssetBase baseAsset = new AssetBase();

            baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 };
            baseAsset.Name = "Name1234567 ΏΏ";
            baseAsset.Description = "Description TEstttt ΏΏΏÿÿ";
            baseAsset.FullID = UUID.Random();
            baseAsset.Local = true;
            baseAsset.Temporary = true;
            baseAsset.Type = 5;
            baseAsset.Metadata.CreationDate = DateTime.Now;

            int start = Environment.TickCount;
            _client.StoreAsset(baseAsset);
            Console.WriteLine("Time to store: {0}", Environment.TickCount - start);

            start = Environment.TickCount;
            AssetBase cfAsset = _client.RequestAssetSync(baseAsset.FullID);
            Console.WriteLine("Time to read: {0}", Environment.TickCount - start);

            CompareObjects comp = new CompareObjects();
            comp.CompareStaticFields = false;
            comp.CompareStaticProperties = false;

            Assert.IsTrue(comp.Compare(baseAsset, cfAsset), comp.DifferencesString);
            CollectionAssert.AreEqual(baseAsset.Data, cfAsset.Data);

            start = Environment.TickCount;
            //cleanup
            _client.PurgeAssetSync(baseAsset.FullID);
            Console.WriteLine("Time to purge: {0}", Environment.TickCount - start);
        }
        public bool PostAsset(string url, AssetBase asset)
        {
            if (asset != null)
            {
                // See long comment in AssetCache.AddAsset
                if (!asset.Temporary || asset.Local)
                {
                    // We need to copy the asset into a new asset, because
                    // we need to set its ID to be URL+UUID, so that the
                    // HGAssetService dispatches it to the remote grid.
                    // It's not pretty, but the best that can be done while
                    // not having a global naming infrastructure
                    AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID);
                    Copy(asset, asset1);
                    try
                    {
                        asset1.ID = url + "/" + asset.ID;
                    }
                    catch
                    {
                        m_log.Warn("[HG ASSET MAPPER]: Oops.");
                    }

                    m_scene.AssetService.Store(asset1);
                    m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
                }
                return true;
           }
            else
                m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache.");

            return false;
        }
        public void TestBasicCacheRetrieval()
        {
            Cache.DiskWriteBackCache wbc = new Cache.DiskWriteBackCache();

            AssetBase baseAsset = new AssetBase();

            baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 };
            baseAsset.Name = "Name";
            baseAsset.Description = "Description";
            baseAsset.FullID = UUID.Random();
            baseAsset.Local = true;
            baseAsset.Temporary = true;
            baseAsset.Type = 5;
            baseAsset.Metadata.CreationDate = DateTime.Now;

            var stAsset = StratusAsset.FromAssetBase(baseAsset);

            wbc.StoreAsset(stAsset);

            CompareObjects comp = new CompareObjects();
            comp.CompareStaticFields = false;
            comp.CompareStaticProperties = false;

            var cacheAsset = wbc.GetAsset(baseAsset.FullID.Guid);

            Assert.IsTrue(comp.Compare(cacheAsset, stAsset), comp.DifferencesString);
            CollectionAssert.AreEqual(cacheAsset.Data, stAsset.Data);
        }
Example #7
0
 public AssetLandmark(AssetBase a)
     : base(a.ID, a.Name, a.TypeAsset, a.CreatorID)
 {
     Data = a.Data;
     Description = a.Description;
     InternData();
 }
Example #8
0
 public void AssetReceived(AssetBase asset, bool isTexture)
 {
     Console.WriteLine("[RegionClient]: Asset received " + asset.FullID);
     if (isTexture)
     {
         TextureSender sender = null;
         lock (textureSenders)
         {
             if (textureSenders.TryGetValue(asset.FullID, out sender))
                 textureSenders.Remove(asset.FullID);
             else
                 Console.WriteLine("[RegionClient]: received texture but there is no texture sender!");
         }
         if (sender != null)
             sender.TextureReceived(asset);
     }
     else
     {
         AssetSender sender = null;
         lock (assetSenders)
         {
             if (assetSenders.TryGetValue(asset.FullID, out sender))
                 assetSenders.Remove(asset.FullID);
             else
                 Console.WriteLine("[RegionClient]: received asset but there is no asset sender!");
         }
         if (sender != null)
             sender.AssetReceived(asset);
     }
 }
 public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename)
 {
     m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId.ToString());
     m_asset.Data = new byte[0];
     m_asset.Description = "empty";
     m_asset.Local = true;
     m_asset.Temporary = true;
 }
Example #10
0
 private void Save(AssetBase asset)
 {
     AssetBase temp = (AssetBase)manager.Get(typeof(AssetBase), asset.FullID);
     if (temp == null)
     {
         manager.Insert(asset);
     }
 }
Example #11
0
        public string Store(AssetBase asset)
        {
            m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID);
            
            Assets[asset.ID] = asset;

            return asset.ID;
        }
Example #12
0
 public AssetLandmark(AssetBase a)
 {
     Data = a.Data;
     FullID = a.FullID;
     Type = a.Type;
     Name = a.Name;
     Description = a.Description;
     InternData();
 }
        public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");

            Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
        }
Example #14
0
        public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
        {
            AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID.ToString());
            asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
            asset.Description = "MRM Image";
            asset.Local = false;
            asset.Temporary = temporary;
            m_scene.AssetService.Store(asset);

            return asset.FullID;
        }
 public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename)
 {
     m_asset = new AssetBase();
     m_asset.FullID = UUID.Zero;
     m_asset.Type = type;
     m_asset.Data = new byte[0];
     m_asset.Name = pClientFilename;
     m_asset.Description = "empty";
     m_asset.Local = true;
     m_asset.Temporary = true;
 }
Example #16
0
        public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
        {
            AssetBase asset = new AssetBase();
            asset.FullID = UUID.Random();
            asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
            asset.Name = "MRMDynamicImage";
            asset.Type = 0;
            asset.Description = "MRM Image";
            asset.Local = false;
            asset.Temporary = temporary;
            m_scene.AssetService.Store(asset);

            return asset.FullID;
        }
 override public void StoreAsset(AssetBase asset)
 {
     AssetBase temp = (AssetBase)manager.Get(typeof(AssetBase), asset.FullID);
     if (temp == null)
     {
         m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
         manager.Insert(asset);
     }
     else
     {
         m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID);
         manager.Update(asset);
     }
 }
        public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            XmlSerializer xs = new XmlSerializer(typeof(AssetMetadata));

            byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);

            Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");

            Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
        }
Example #19
0
        public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
        {
            AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", AssetType.Texture,
                                            m_scene.RegionInfo.RegionID)
                                  {
                                      Data = OpenJPEG.EncodeFromImage(data, lossless),
                                      Description = "MRM Image",
                                      Flags = (temporary) ? AssetFlags.Temperary : 0
                                  };
            asset.FillHash();
            asset.ID = m_scene.AssetService.Store(asset);

            return asset.ID;
        }
Example #20
0
 //Constructor
 public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
 {
     
     m_imagestore = new Dictionary<UUID,J2KImage>();
     m_priorities = new SortedList<double,UUID>();
     m_priorityresolver = new Dictionary<int, int>();
     m_client = client;
     m_assetCache = pAssetCache;
     if (pAssetCache != null)
         m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f");
     else
         m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
     m_j2kDecodeModule = pJ2kDecodeModule;
 }
Example #21
0
        public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
        {
            List<WearableCacheItem> ret = new List<WearableCacheItem>();
            if (pInput.Type == OSDType.Array)
            {
                OSDArray itemarray = (OSDArray) pInput;
                foreach (OSDMap item in itemarray)
                {
                    ret.Add(new WearableCacheItem()
                                {
                                    TextureIndex = item["textureindex"].AsUInteger(),
                                    CacheId = item["cacheid"].AsUUID(),
                                    TextureID = item["textureid"].AsUUID()
                                });
                    
                    if (dataCache != null && item.ContainsKey("assetdata"))
                    {
                        AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString());
                        asset.Temporary = true;
                        asset.Data = item["assetdata"].AsBinary();
                        dataCache.Cache(asset);
                    }
                }
            }
            else if (pInput.Type == OSDType.Map)
            {
                OSDMap item = (OSDMap) pInput;
                ret.Add(new WearableCacheItem(){
                                    TextureIndex = item["textureindex"].AsUInteger(),
                                    CacheId = item["cacheid"].AsUUID(),
                                    TextureID = item["textureid"].AsUUID()
                                });
                if (dataCache != null && item.ContainsKey("assetdata"))
                {
                    string assetCreator = item["assetcreator"].AsString();
                    string assetName = item["assetname"].AsString();
                    AssetBase asset = new AssetBase(item["textureid"].AsUUID(), assetName, (sbyte)AssetType.Texture, assetCreator);
                    asset.Temporary = true;
                    asset.Data = item["assetdata"].AsBinary();
                    dataCache.Cache(asset);
                }
            }
            else
            {
                return new WearableCacheItem[0];
            }
            return ret.ToArray();

        }
        public void TestSetAppearance()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            UUID bakedTextureID = TestHelpers.ParseTail(0x2);

            // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
            // to the AssetService, which will then store temporary and local assets permanently
            CoreAssetCache assetCache = new CoreAssetCache();
            
            AvatarFactoryModule afm = new AvatarFactoryModule();
            TestScene scene = new SceneHelpers(assetCache).SetupScene();
            SceneHelpers.SetupSceneModules(scene, afm);
            ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);

            // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
            AssetBase bakedTextureAsset;
            bakedTextureAsset 
                = new AssetBase(
                    bakedTextureID, "Test Baked Texture", (sbyte)AssetType.Texture, userId.ToString());
            bakedTextureAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet
            bakedTextureAsset.Temporary = true;
            bakedTextureAsset.Local = true;
            scene.AssetService.Store(bakedTextureAsset);

            byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
            for (byte i = 0; i < visualParams.Length; i++)
                visualParams[i] = i;

            Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
            uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
            Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);

            int rebakeRequestsReceived = 0;
            ((TestClient)sp.ControllingClient).OnReceivedSendRebakeAvatarTextures += id => rebakeRequestsReceived++;

            // This is the alpha texture
            eyesFace.TextureID = bakedTextureID;
            afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
    
            Assert.That(rebakeRequestsReceived, Is.EqualTo(0));

            AssetBase eyesBake = scene.AssetService.Get(bakedTextureID.ToString());
            Assert.That(eyesBake, Is.Not.Null);
            Assert.That(eyesBake.Temporary, Is.True);
            Assert.That(eyesBake.Local, Is.True);
        }
Example #23
0
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <param name="asset">The serialized asset for this item</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        private static InventoryItemBase AddInventoryItem(
            Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
        {
            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)itemType;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);

            item.Folder = folder.ID;
            scene.AddInventoryItem(item);

            return item;
        }
        public void FixtureInit()
        {
            using (
                Stream resource
                    = GetType().Assembly.GetManifestResourceStream(
                        "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
            {
                using (BinaryReader br = new BinaryReader(resource))
                {
                    m_testImageAsset
                        = new AssetBase(
                            TestHelpers.ParseTail(0x1),
                            "Test Image",
                            (sbyte)AssetType.Texture,
                            TestHelpers.ParseTail(0x2).ToString());

                    m_testImageAsset.Data = br.ReadBytes(99999999);
                }
            }
        }
        public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);

            byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);

            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");            
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); 

            actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash.");
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            
            actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response);
            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash.");
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
        }
Example #26
0
        public void TextureReceived(string id, Object sender, AssetBase asset)
        {
            if (asset == null)
            {
                Console.WriteLine("[RegionClient]: Texture not found " + id);
                Done(new UUID(id));
                return;
            }

            if ((sender != null) && (sender is TextureSender))
            {
                Console.WriteLine("[RegionClient]: Texture received " + asset.FullID);
                TextureSender tsender = (TextureSender)sender;
                tsender.TextureReceived(asset);
            }
            else
            {
                Console.WriteLine("[RegionClient]: Something wrong with texture sender for texture " + asset.FullID);
               }
        }
        public override byte[] Handle(string path, Stream request,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string body = GetBodyAsString(request);
            OSDMap map = WebUtils.GetOSDMap(Util.Decompress(body));
            IGridRegistrationService urlModule =
                m_registry.RequestModuleInterface<IGridRegistrationService>();
            if (m_SessionID != "" && urlModule != null)
                if (!urlModule.CheckThreatLevel(m_SessionID, "Asset_Update", ThreatLevel.Full))
                    return new byte[0];
            UUID newID;
            if (map.ContainsKey("Method") && map["Method"] == "UpdateContent")
                m_AssetService.UpdateContent(map["ID"].AsUUID(), map["Data"].AsBinary(), out newID);
            else
            {
                AssetBase asset = new AssetBase();
                asset = asset.Unpack(map);
                newID = m_AssetService.Store(asset);
            }

            return Encoding.UTF8.GetBytes(newID.ToString());
        }
        public void FixtureInit()
        {
            // Don't allow tests to be bamboozled by asynchronous events.  Execute everything on the same thread.
            Util.FireAndForgetMethod = FireAndForgetMethod.None;

            using (
                Stream resource
                    = GetType().Assembly.GetManifestResourceStream(
                        "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
            {
                using (BinaryReader br = new BinaryReader(resource))
                {
                    m_testImageAsset
                        = new AssetBase(
                            TestHelpers.ParseTail(0x1),
                            "Test Image",
                            (sbyte)AssetType.Texture,
                            TestHelpers.ParseTail(0x2).ToString());

                    m_testImageAsset.Data = br.ReadBytes(99999999);
                }
            }
        }
Example #29
0
        public void TestSimpleConversionFromBaseAsset()
        {
            AssetBase baseAsset = new AssetBase();

            baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 };
            baseAsset.Name = "Name";
            baseAsset.Description = "Description";
            baseAsset.FullID = UUID.Random();
            baseAsset.Local = true;
            baseAsset.Temporary = true;
            baseAsset.Type = 5;
            baseAsset.Metadata.CreationDate = DateTime.Now;

            var stAsset = StratusAsset.FromAssetBase(baseAsset);

            Assert.AreEqual(baseAsset.FullID.Guid, stAsset.Id);
            CollectionAssert.AreEqual(baseAsset.Data, stAsset.Data);
            Assert.AreEqual(baseAsset.Description, stAsset.Description);
            Assert.AreEqual(baseAsset.Local, stAsset.Local);
            Assert.AreEqual(baseAsset.Name, stAsset.Name);
            Assert.AreEqual(baseAsset.Temporary, stAsset.Temporary);
            Assert.AreEqual(baseAsset.Type, stAsset.Type);
            Assert.AreEqual(baseAsset.Metadata.CreationDate, stAsset.CreateTime);
        }
Example #30
0
            /// <summary>
            /// Called once new texture data has been received for this updater.
            /// </summary>
            public void DataReceived(byte[] data, Scene scene)
            {
                SceneObjectPart part = scene.GetSceneObjectPart(PrimID);

                if (part == null || data == null || data.Length <= 1)
                {
                    string msg = 
                        String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
                    scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,
                                  0, part.ParentGroup.RootPart.AbsolutePosition, part.Name, part.UUID, false);
                    return;
                }

                byte[] assetData = null;
                AssetBase oldAsset = null;
                
                if (BlendWithOldTexture)
                {
                    Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
                    if (defaultFace != null)
                    {
                        oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());

                        if (oldAsset != null)
                            assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
                    }
                }

                if (assetData == null)
                {
                    assetData = new byte[data.Length];
                    Array.Copy(data, assetData, data.Length);
                }

                // Create a new asset for user
                AssetBase asset
                    = new AssetBase(
                        UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture,
                        scene.RegionInfo.RegionID.ToString());
                asset.Data = assetData;
                asset.Description = String.Format("URL image : {0}", Url);
                asset.Local = false;
                asset.Temporary = ((Disp & DISP_TEMP) != 0);
                scene.AssetService.Store(asset);

                IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>();
                if (cacheLayerDecode != null)
                {
                    cacheLayerDecode.Decode(asset.FullID, asset.Data);
                    cacheLayerDecode = null;
                }

                UUID oldID = UUID.Zero;

                lock (part)
                {
                    // mostly keep the values from before
                    Primitive.TextureEntry tmptex = part.Shape.Textures;

                    // remove the old asset from the cache
                    oldID = tmptex.DefaultTexture.TextureID;
                    
                    if (Face == ALL_SIDES)
                    {
                        tmptex.DefaultTexture.TextureID = asset.FullID;
                    }
                    else
                    {
                        try
                        {
                            Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
                            texface.TextureID = asset.FullID;
                            tmptex.FaceTextures[Face] = texface;
                        }
                        catch (Exception)
                        {
                            tmptex.DefaultTexture.TextureID = asset.FullID;
                        }
                    }

                    // I'm pretty sure we always want to force this to true
                    // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
                    // tmptex.DefaultTexture.Fullbright = true;

                    part.UpdateTexture(tmptex);
                }

                if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
                {
                    if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
                    if (oldAsset != null)
                    {
                        if (oldAsset.Temporary == true)
                        {
                            scene.AssetService.Delete(oldID.ToString());
                        }
                    }
                }
            }
Example #31
0
 public AssetLandmark(AssetBase a) : base(a.FullID, a.Name, a.Type, a.Metadata.CreatorID)
 {
     Data        = a.Data;
     Description = a.Description;
     InternData();
 }