Exemplo n.º 1
0
 public void run(object o)
 {
     for (int i = 0; i < arrassets.Length; i++)
     {
         AssetBase ab = sn.CommsManager.AssetCache.GetAsset(arrassets[i], true);
         if (ab != null && ab.Data != null)
         {
             j2kdecode.syncdecode(arrassets[i], ab.Data);
         }
     }
     ThreadTracker.Remove(thisthread);
 }
Exemplo n.º 2
0
 public void run(object o)
 {
     for (int i = 0; i < arrassets.Length; i++)
     {
         AssetBase ab = sn.AssetService.Get(arrassets[i].ToString());
         if (ab != null && ab.Data != null)
         {
             j2kdecode.syncdecode(arrassets[i], ab.Data);
         }
     }
     ThreadTracker.Remove(thisthread);
 }
Exemplo n.º 3
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 (data == null)
                {
                    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;
                AssetBase oldAsset = null;

                if (BlendWithOldTexture)
                {
                    UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID;
                    oldAsset = scene.CommsManager.AssetCache.GetAsset(lastTextureID, true);
                    if (oldAsset != null)
                    {
                        assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
                    }
                    else
                    {
                        assetData = new byte[data.Length];
                        Array.Copy(data, assetData, data.Length);
                    }
                }
                else
                {
                    assetData = new byte[data.Length];
                    Array.Copy(data, assetData, data.Length);
                }

                // Create a new asset for user
                AssetBase asset = new AssetBase();

                asset.FullID      = UUID.Random();
                asset.Data        = assetData;
                asset.Name        = "DynamicImage" + Util.RandomClass.Next(1, 10000);
                asset.Type        = 0;
                asset.Description = "dynamic image";
                asset.Local       = false;
                asset.Temporary   = true;
                scene.CommsManager.AssetCache.AddAsset(asset);

                LastAssetID = asset.FullID;

                IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface <IJ2KDecoder>();

                if (cacheLayerDecode != null)
                {
                    cacheLayerDecode.syncdecode(asset.FullID, asset.Data);
                }
                cacheLayerDecode = null;

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

                // remove the old asset from the cache
                UUID oldID = tmptex.DefaultTexture.TextureID;

                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.Shape.Textures = tmptex;
                part.ScheduleFullUpdate();

                scene.CommsManager.AssetCache.ExpireAsset(oldID);
            }
            /// <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;
                AssetBase oldAsset = null;

                if (BlendWithOldTexture)
                {
                    UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID;
                    oldAsset = scene.AssetService.Get(lastTextureID.ToString());
                    if (oldAsset != null)
                    {
                        assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
                    }
                    else
                    {
                        assetData = new byte[data.Length];
                        Array.Copy(data, assetData, data.Length);
                    }
                }
                else
                {
                    assetData = new byte[data.Length];
                    Array.Copy(data, assetData, data.Length);
                }

                // Create a new asset for user
                AssetBase asset = new AssetBase();

                asset.FullID      = UUID.Random();
                asset.Data        = assetData;
                asset.Name        = "DynamicImage" + Util.RandomClass.Next(1, 10000);
                asset.Type        = 0;
                asset.Description = String.Format("URL image : {0}", Url);
                asset.Local       = false;
                asset.Temporary   = ((Disp & DISP_TEMP) != 0);
                scene.AssetService.Store(asset);
//                scene.CommsManager.AssetCache.AddAsset(asset);

                IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface <IJ2KDecoder>();

                if (cacheLayerDecode != null)
                {
                    cacheLayerDecode.syncdecode(asset.FullID, asset.Data);
                    cacheLayerDecode = null;
                    LastAssetID      = asset.FullID;
                }

                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))
                {
                    // scene.CommsManager.AssetCache.ExpireAsset(oldID);
                    scene.AssetService.Delete(oldID.ToString());
                }
            }