コード例 #1
0
        /// <summary>
        /// Exectute the command
        /// </summary>
        /// <param name="args"></param>
        /// <param name="fromAgentID"></param>
        /// <returns></returns>
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 1)
            {
                return("Usage: viewnote [notecard asset uuid]");
            }
            UUID note;

            if (!UUID.TryParse(args[0], out note))
            {
                return("First argument expected agent UUID.");
            }

            System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);

            System.Text.StringBuilder result = new System.Text.StringBuilder();


            // define a delegate to handle the reply
            AssetManager.AssetReceivedCallback del = delegate(AssetDownload transfer, Asset asset)
            {
                if (transfer.Success)
                {
                    result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
                    waitEvent.Set();
                }
            };

            // verify asset is loaded in store
            if (Client.Inventory.Store.Contains(note))
            {
                // retrieve asset from store
                InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
                // subscribe to reply event
                Client.Assets.OnAssetReceived += del;

                // make request for asset
                Client.Assets.RequestInventoryAsset(ii, true);

                // wait for reply or timeout
                if (!waitEvent.WaitOne(10000, false))
                {
                    result.Append("Timeout waiting for notecard to download.");
                }
                // unsubscribe from reply event
                Client.Assets.OnAssetReceived -= del;
            }
            else
            {
                result.Append("Cannot find asset in inventory store, use 'i' to populate store");
            }

            // return results
            return(result.ToString());
        }
コード例 #2
0
        private void UpdateAppearanceFromWearables(bool bake)
        {
            lock (AgentTextures)
            {
                for (int i = 0; i < AgentTextures.Length; i++)
                    AgentTextures[i] = UUID.Zero;
            }

            // Register an asset download callback to get wearable data
            AssetManager.AssetReceivedCallback assetCallback = new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
            
            AssetManager.AssetUploadedCallback uploadCallback = new AssetManager.AssetUploadedCallback(Assets_OnAssetUploaded);
            Assets.OnAssetReceived += assetCallback;
            
            Assets.OnAssetUploaded += uploadCallback;

            // Download assets for what we are wearing and fill in AgentTextures
            DownloadWearableAssets();
            WearablesDownloadedEvent.WaitOne();

            // Unregister the asset download callback
            Assets.OnAssetReceived -= assetCallback;

            // Check if anything needs to be rebaked
            if (bake) RequestCachedBakes();

            // Tell the sim what we are wearing
            SendAgentIsNowWearing();

            // Wait for cached layer check to finish
            if (bake) CachedResponseEvent.WaitOne();

            // Unregister the image download and asset upload callbacks
            //Assets.OnImageReceived -= imageCallback;
            Assets.OnAssetUploaded -= uploadCallback;

            Log.DebugLog("CachedResponseEvent completed");

            #region Send Appearance

            Primitive.TextureEntry te = null;

            ObjectManager.NewAvatarCallback updateCallback =
                delegate(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation)
                {
                    if (avatar.LocalID == Self.LocalID)
                    {
                        if (avatar.Textures.FaceTextures != null)
                        {
                            bool match = true;

                            for (uint i = 0; i < AgentTextures.Length; i++)
                            {
                                Primitive.TextureEntryFace face = avatar.Textures.FaceTextures[i];

                                if (face == null)
                                {
                                    // If the texture is UUID.Zero the face should be null
                                    if (AgentTextures[i] != UUID.Zero)
                                    {
                                        match = false;
                                        break;
                                    }
                                }
                                else if (face.TextureID != AgentTextures[i] && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                                {
                                    Log.DebugLog("*** FACE is " + ((TextureIndex)i).ToString() + " " + face.TextureID.ToString() + " Agent Texture is " + AgentTextures[i].ToString());
                                    match = false;
                                    //break;
                                }
                            }

                            if (!match)
                                Log.Log("TextureEntry mismatch after updating our appearance", Helpers.LogLevel.Warning);

                            te = avatar.Textures;
                            UpdateEvent.Set();
                        }
                        else
                        {
                            Log.Log("Received an update for our avatar with a null FaceTextures array",
                                Helpers.LogLevel.Warning);
                        }
                    }
                };
            Objects.OnNewAvatar += updateCallback;

            // Send all of the visual params and textures for our agent
            SendAgentSetAppearance();

            // Wait for the ObjectUpdate to come in for our avatar after changing appearance
            if (UpdateEvent.WaitOne(1000 * 60, false))
            {
                if (OnAppearanceUpdated != null)
                {
                    try { OnAppearanceUpdated(te); }
                    catch (Exception e) { Log.Log(e.Message, Helpers.LogLevel.Error, e); }
                }
            }
            else
            {
                Log.Log("Timed out waiting for our appearance to update on the simulator", Helpers.LogLevel.Warning);
            }

            Objects.OnNewAvatar -= updateCallback;
            Log.Log("Appearance update completed",Helpers.LogLevel.Info);

            #endregion Send Appearance
        }
コード例 #3
0
        private void UpdateAppearanceFromWearables(bool bake)
        {
            lock (AgentTextures)
            {
                for (int i = 0; i < AgentTextures.Length; i++)
                    AgentTextures[i] = LLUUID.Zero;
            }

            // Register an asset download callback to get wearable data
            AssetManager.AssetReceivedCallback assetCallback = new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
            AssetManager.ImageReceivedCallback imageCallback = new AssetManager.ImageReceivedCallback(Assets_OnImageReceived);
            AssetManager.AssetUploadedCallback uploadCallback = new AssetManager.AssetUploadedCallback(Assets_OnAssetUploaded);
            Assets.OnAssetReceived += assetCallback;
            Assets.OnImageReceived += imageCallback;
            Assets.OnAssetUploaded += uploadCallback;

            // Download assets for what we are wearing and fill in AgentTextures
            DownloadWearableAssets();
            WearablesDownloadedEvent.WaitOne();

            // Unregister the asset download callback
            Assets.OnAssetReceived -= assetCallback;

            if (Client.Settings.DEBUG)
            {
                StringBuilder tex = new StringBuilder();

                for (int i = 0; i < AgentTextures.Length; i++)
                    if (AgentTextures[i] != LLUUID.Zero)
                        tex.AppendFormat("{0} = {1}\n", (TextureIndex)i, AgentTextures[i]);

                Client.DebugLog("AgentTextures:" + Environment.NewLine + tex.ToString());
            }

            // Check if anything needs to be rebaked
            if (bake) RequestCachedBakes();

            // Tell the sim what we are wearing
            SendAgentIsNowWearing();

            // Wait for cached layer check to finish
            if (bake) CachedResponseEvent.WaitOne();

            // Unregister the image download and asset upload callbacks
            Assets.OnImageReceived -= imageCallback;
            Assets.OnAssetUploaded -= uploadCallback;

            Client.DebugLog("CachedResponseEvent completed");

            #region Send Appearance

            LLObject.TextureEntry te = null;

            ObjectManager.NewAvatarCallback updateCallback =
                delegate(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation)
                {
                    if (avatar.LocalID == Client.Self.LocalID)
                    {
                        if (avatar.Textures.FaceTextures != null)
                        {
                            bool match = true;

                            for (uint i = 0; i < AgentTextures.Length; i++)
                            {
                                LLObject.TextureEntryFace face = avatar.Textures.FaceTextures[i];

                                if (face == null)
                                {
                                    // If the texture is LLUUID.Zero the face should be null
                                    if (AgentTextures[i] != LLUUID.Zero)
                                    {
                                        match = false;
                                        break;
                                    }
                                }
                                else if (face.TextureID != AgentTextures[i])
                                {
                                    match = false;
                                    break;
                                }
                            }

                            if (!match)
                                Client.Log("TextureEntry mismatch after updating our appearance", Helpers.LogLevel.Warning);

                            te = avatar.Textures;
                            UpdateEvent.Set();
                        }
                        else
                        {
                            Client.Log("Received an update for our avatar with a null FaceTextures array",
                                Helpers.LogLevel.Warning);
                        }
                    }
                };
            Client.Objects.OnNewAvatar += updateCallback;

            // Send all of the visual params and textures for our agent
            SendAgentSetAppearance();

            // Wait for the ObjectUpdate to come in for our avatar after changing appearance
            if (UpdateEvent.WaitOne(1000 * 60, false))
            {
                if (OnAppearanceUpdated != null)
                {
                    try { OnAppearanceUpdated(te); }
                    catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
                }
            }
            else
            {
                Client.Log("Timed out waiting for our appearance to update on the simulator", Helpers.LogLevel.Warning);
            }

            Client.Objects.OnNewAvatar -= updateCallback;

            #endregion Send Appearance
        }
コード例 #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="client">Reference to <code>SecondLife</code> client</param>
        public TexturePipeline(GridClient client)
        {
            Running = true;

            RequestQueue = new Queue<UUID>();
            CurrentRequests = new Dictionary<UUID, int>(MAX_TEXTURE_REQUESTS);

            RenderReady = new Dictionary<UUID, ImageDownload>();

            resetEvents = new AutoResetEvent[MAX_TEXTURE_REQUESTS];
            threadpoolSlots = new int[MAX_TEXTURE_REQUESTS];

            // pre-configure autoreset events/download slots
            for (int i = 0; i < MAX_TEXTURE_REQUESTS; i++)
            {
                resetEvents[i] = new AutoResetEvent(false);
                threadpoolSlots[i] = -1;
            }

            Client = client;

            DownloadCallback = new AssetManager.ImageReceivedCallback(Assets_OnImageReceived);
            DownloadProgCallback = new AssetManager.ImageReceiveProgressCallback(Assets_OnImageReceiveProgress);
            Client.Assets.OnImageReceived += DownloadCallback;
            Client.Assets.OnImageReceiveProgress += DownloadProgCallback;

            // Fire up the texture download thread
            downloadMaster = new Thread(new ThreadStart(DownloadThread));
            downloadMaster.Start();
        }