コード例 #1
0
        public void Init(UUID id)
        {
            if (id == UUID.Zero)
            {
                return;
            }
            AssetType assetType = AssetType.Texture;
            SimAsset  sa        = SimAssetStore.FindOrCreateAsset(id, assetType);

            if (!sa.NeedsRequest)
            {
                return;
            }

            {
                StartTextureDownload(id);
            }
            sa.NeedsRequest = false;
            lock (AssetRequestType)
            {
                if (AssetRequestType.ContainsKey(id))
                {
                    return;
                }
                AssetRequestType[id] = AssetType.Texture;
            }

            // Callbacks
            client.Assets.RequestImage(id, ImageType.Normal, 101300.0f, 0, 0, delegate(TextureRequestState state, AssetTexture assetTexture)
            {
                if (state == TextureRequestState.Finished)
                {
                    Assets_OnImageReceived(assetTexture);
                    sa.SetAsset(assetTexture);
                    return;
                }
                else if (state == TextureRequestState.Progress)
                {
                    // DisplayPartialImage(assetTexture);
                }
                else if (state == TextureRequestState.Timeout)
                {
                    AssetRequestType.Remove(id);
                }
            }, false);
        }
コード例 #2
0
        internal void OnAssetDownloaded(UUID uUID, Asset asset)
        {
            EnsureCached(asset, uUID);
            WorldObjects.RegisterUUIDMaybe(uUID, asset);
            SimAsset A = SimAssetStore.FindOrCreateAsset(uUID, asset.AssetType);

            A.SetAsset(asset);
            //A.TypeData = asset.AssetData;



            if (false)
            {
                BotClient      Client = this.client;
                AutoResetEvent UploadCompleteEvent = new AutoResetEvent(false);
                if (Client.AnimationFolder == UUID.Zero)
                {
                    Client.AnimationFolder = Client.Inventory.FindFolderForType(AssetType.Animation);
                }

                DateTime start = new DateTime();
                Client.Inventory.RequestCreateItemFromAsset(asset.AssetData, A.Name, "Anim captured " + uUID,
                                                            AssetType.Animation,
                                                            InventoryType.Animation, Client.AnimationFolder,
                                                            delegate(bool success, string status, UUID itemID,
                                                                     UUID assetID)
                {
                    WriteLine(
                        String.Format(
                            "RequestCreateItemFromAsset() returned: Success={0}, Status={1}, ItemID={2}, AssetID={3}",
                            success, status, itemID, assetID));
                    WriteLine(String.Format("Upload took {0}",
                                            DateTime.Now.
                                            Subtract(start)));
                    UploadCompleteEvent.Set();
                });

                UploadCompleteEvent.WaitOne();

                //A.Name
                //SetAnimationName(asset.AssetID, s);
            }
            //              Debug(s);
            //                        RegisterUUID(asset.AssetID, s);
        }
コード例 #3
0
        public ImageDownload StartTextureDownload(UUID id)
        {
            AssetType  type     = AssetType.Texture;
            SimAsset   simAsset = SimAssetStore.FindOrCreateAsset(id, type);
            AssetCache Cache    =
                (RegionMasterTexturePipeline == null ? null : RegionMasterTexturePipeline.Cache);

            if (Cache != null && Cache.HasAsset(id

#if COGBOT_LIBOMV
                                                , type
#endif
                                                ))
            {
                ImageDownload dl = Cache.GetCachedImage(id);
                if (dl != null)
                {
                    simAsset.SetAsset(dl);
                }
                return(dl);
            }
            lock (TexturesSkipped) if (TexturesSkipped.Contains(id))
                {
                    return(null);
                }
            lock (AssetRequestType)
            {
                if (AssetRequestType.ContainsKey(id))
                {
                    return(null);
                }
                AssetRequestType[id] = AssetType.Texture;
            }
            TextureRequested++;
            SlowConnectedQueue.Enqueue(() => client.Assets.RequestImage(id, ImageType.Normal, RegionMasterTexturePipeline_OnDownloadFinished));
            return(null);
        }