public void SendStyle(EStyle Style)
 {
     StatusIconProvider?.StyleChanged(Style);
     if (!AssetCache.HasAsset(Style, EAsset.MenuIcon))
     {
         Image newAsset = MenuItem.GetIcon(Style);
         AssetCache.RegisterAsset(Style, EAsset.MenuIcon, newAsset);
         pbIcon.Image = newAsset;
     }
     else
     {
         pbIcon.Image = AssetCache.GetAsset(Style, EAsset.MenuIcon);
     }
 }
Example #2
0
        public MeshingResult CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, OpenMetaverse.Vector3 size, float lod, ShapeType desiredShape, bool preScale)
        {
            Vector3 szvec   = new Vector3(size.X, size.Y, size.Z);
            ulong   meshKey = primShape.GetMeshKey(szvec, lod);

            try
            {
                if (primShape.SculptEntry && ((primShape.SculptData == null) || (primShape.SculptData.Length == 0)))
                {
                    //preload the sculpt/mesh data
                    AssetBase asset = _assetCache.GetAsset(primShape.SculptTexture, AssetRequestInfo.InternalRequest());
                    if (asset == null)
                    {
                        return(null);
                    }

                    primShape.SculptData = asset.Data;
                }

                if (primShape.SculptEntry == false ||
                    (primShape.SculptEntry == true && (SculptType)primShape.SculptType != SculptType.Mesh))
                {
                    return(ExtractTrimeshFromPrimOrSculpt(primName, primShape, ref size, lod, preScale, meshKey));
                }
                else //mesh
                {
                    return(ExtractMeshingResultFromMesh(primName, primShape, ref size, lod, preScale, desiredShape, meshKey));
                }
            }
            finally
            {
                //we dont need the sculpt data around anymore
                primShape.SculptData = null;
            }
        }
Example #3
0
        /// <summary>
        /// Start a script which is in this prim's inventory.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
        {
            // m_log.InfoFormat(
            //     "[PRIM INVENTORY]: " +
            //     "Starting script {0}, {1} in prim {2}, {3}",
            //     item.Name, item.ItemID, Name, UUID);

            if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
            {
                return;
            }

            m_part.AddFlag(PrimFlags.Scripted);

            if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
            {
                if (stateSource == 1 && // Prim crossing
                    m_part.ParentGroup.Scene.m_trustBinaries)
                {
                    m_items[item.ItemID].PermsMask    = 0;
                    m_items[item.ItemID].PermsGranter = UUID.Zero;
                    m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
                        m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
                    m_part.ParentGroup.AddActiveScriptCount(1);
                    m_part.ScheduleFullUpdate();
                    return;
                }
                IAssetCache cache = m_part.ParentGroup.Scene.CommsManager.AssetCache;

                cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset)
                {
                    if (null == asset)
                    {
                        m_log.ErrorFormat(
                            "[PRIM INVENTORY]: " +
                            "Couldn't start script {0}, {1} since asset ID {2} could not be found",
                            item.Name, item.ItemID, item.AssetID);
                    }
                    else
                    {
                        if (m_part.ParentGroup.m_savedScriptState != null)
                        {
                            RestoreSavedScriptState(item.OldItemID, item.ItemID);
                        }
                        m_items[item.ItemID].PermsMask    = 0;
                        m_items[item.ItemID].PermsGranter = UUID.Zero;
                        string script = Utils.BytesToString(asset.Data);
                        m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
                            m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
                        m_part.ParentGroup.AddActiveScriptCount(1);
                        m_part.ScheduleFullUpdate();
                    }
                }, false);
            }
        }
Example #4
0
        protected internal void Execute()
        {
            m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} assets", m_repliesRequired);

            // We can stop here if there are no assets to fetch
            if (m_repliesRequired == 0)
            {
                m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids);
            }

            foreach (UUID uuid in m_uuids)
            {
                m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
            }
        }
            public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
            {
                Hashtable responsedata = new Hashtable();

                responsedata["int_response_code"]   = 400; //501; //410; //404;
                responsedata["content_type"]        = "text/plain";
                responsedata["keepalive"]           = false;
                responsedata["str_response_string"] = "Request wasn't what was expected";

                UUID meshID = UUID.Zero;

                if ((request.ContainsKey("mesh_id")) &&
                    (UUID.TryParse(request["mesh_id"].ToString(), out meshID)))
                {
                    if (m_AssetCache == null)
                    {
                        responsedata["int_response_code"]   = 404; //501; //410; //404;
                        responsedata["str_response_string"] = "The asset service is unavailable.  So is your mesh.";
                        return(responsedata);
                    }

                    AssetBase mesh = m_AssetCache.GetAsset(meshID, AssetRequestInfo.GenericNetRequest());
                    if (mesh != null)
                    {
                        if (mesh.Type == (SByte)AssetType.Mesh)
                        {
                            responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
                            responsedata["content_type"]        = "application/vnd.ll.mesh";
                            responsedata["int_response_code"]   = 200;
                        }
                        // Optionally add additional mesh types here
                        else
                        {
                            responsedata["int_response_code"]   = 404; //501; //410; //404;
                            responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
                            return(responsedata);
                        }
                    }
                    else
                    {
                        responsedata["int_response_code"]   = 404; //501; //410; //404;
                        responsedata["str_response_string"] = "Your Mesh wasn't found.  Sorry!";
                        return(responsedata);
                    }
                }

                return(responsedata);
            }
        private bool SubmitAssetLoadRequest(LoadUnloadRequest lrq)
        {
            UUID scriptAssetId = this.FindAssetId(lrq);

            if (scriptAssetId != UUID.Zero)
            {
                if (AddAssetWait(scriptAssetId, lrq))
                {
                    _assetCache.GetAsset(scriptAssetId, delegate(UUID i, AssetBase a) { this.AssetReceived(lrq.Prim.LocalId, lrq.ItemId, i, a); }, AssetRequestInfo.InternalRequest());
                }

                return(true);
            }

            return(false);
        }
Example #7
0
 //Constructor
 public LLImageManager(LLClientView client, IAssetCache 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.GetAsset(UUID.Parse("5748decc-f629-461c-9a36-a35a221fe21f"), true);
     }
     else
     {
         m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
     }
     m_j2kDecodeModule = pJ2kDecodeModule;
 }
Example #8
0
        /// <summary>
        /// Get an asset synchronously, potentially using an asynchronous callback.  If the
        /// asynchronous callback is used, we will wait for it to complete.
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        protected AssetBase GetAsset(UUID uuid)
        {
            m_waitingForObjectAsset = true;
            m_assetCache.GetAsset(uuid, AssetRequestCallback, true);

            // The asset cache callback can either
            //
            // 1. Complete on the same thread (if the asset is already in the cache) or
            // 2. Come in via a different thread (if we need to go fetch it).
            //
            // The code below handles both these alternatives.
            lock (this)
            {
                if (m_waitingForObjectAsset)
                {
                    Monitor.Wait(this);
                    m_waitingForObjectAsset = false;
                }
            }

            return(m_requestedObjectAsset);
        }
Example #9
0
        public void RunUpdate()
        {
            //This is where we decide what we need to update
            //and assign the real discardLevel and packetNumber
            //assuming of course that the connected client might be bonkers

            if (!m_hasasset)
            {
                if (!m_asset_requested)
                {
                    m_asset_requested = true;
                    m_assetCache.GetAsset(m_requestedUUID, AssetDataCallback, true);
                }
            }
            else
            {
                if (!m_decoded)
                {
                    //We need to decode the requested image first
                    if (!m_decoderequested)
                    {
                        //Request decode
                        m_decoderequested = true;
                        // Do we have a jpeg decoder?
                        if (m_j2kDecodeModule != null)
                        {
                            if (Data == null)
                            {
                                J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]);
                            }
                            // Send it off to the jpeg decoder
                            m_j2kDecodeModule.decode(m_requestedUUID, Data, J2KDecodedCallback);
                        }
                        else
                        {
                            J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]);
                        }
                    }
                }
                else
                {
                    //discardLevel of -1 means just update the priority
                    if (m_requestedDiscardLevel != -1)
                    {
                        //Evaluate the discard level
                        //First, is it positive?
                        if (m_requestedDiscardLevel >= 0)
                        {
                            if (m_requestedDiscardLevel > Layers.Length - 1)
                            {
                                m_discardLevel = (sbyte)(Layers.Length - 1);
                            }
                            else
                            {
                                m_discardLevel = m_requestedDiscardLevel;
                            }

                            //Calculate the m_stopPacket
                            if (Layers.Length > 0)
                            {
                                m_stopPacket = (uint)GetPacketForBytePosition(Layers[(Layers.Length - 1) - m_discardLevel].End);
                                //I don't know why, but the viewer seems to expect the final packet if the file
                                //is just one packet bigger.
                                if (TexturePacketCount() == m_stopPacket + 1)
                                {
                                    m_stopPacket = TexturePacketCount();
                                }
                            }
                            else
                            {
                                m_stopPacket = TexturePacketCount();
                            }
                            //Don't reset packet number unless we're waiting or it's ahead of us
                            if (m_completedSendAtCurrentDiscardLevel || m_requestedPacketNumber > m_packetNumber)
                            {
                                m_packetNumber = m_requestedPacketNumber;
                            }

                            if (m_packetNumber <= m_stopPacket)
                            {
                                m_completedSendAtCurrentDiscardLevel = false;
                            }
                        }
                    }
                }
            }
        }
 protected override AssetBase GetAsset(UUID assetID)
 {
     return(m_assetProvider.GetAsset(assetID, true)); // TODO IsTexture should be deduced from loaded asset. It is not used in this case.
 }
Example #11
0
        public void RunUpdate()
        {
            //This is where we decide what we need to update
            //and assign the real discardLevel and packetNumber
            //assuming of course that the connected client might be bonkers

            if (!HasAsset)
            {
                if (!m_assetRequested)
                {
                    m_assetRequested = true;
                    AssetService.GetAsset(TextureID, AssetDataCallback, AssetRequestInfo.GenericNetRequest());
                }
            }
            else
            {
                if (!IsDecoded)
                {
                    //We need to decode the requested image first
                    if (!m_decodeRequested)
                    {
                        //Request decode
                        m_decodeRequested = true;
                        // Do we have a jpeg decoder?
                        if (J2KDecoder != null)
                        {
                            if (m_asset == null)
                            {
                                J2KDecodedCallback(TextureID, new OpenJPEG.J2KLayerInfo[0]);
                            }
                            else
                            {
                                // Send it off to the jpeg decoder
                                J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback);
                            }
                        }
                        else
                        {
                            J2KDecodedCallback(TextureID, new OpenJPEG.J2KLayerInfo[0]);
                        }
                    }
                }
                else
                {
                    // Check for missing image asset data
                    if (m_asset == null)
                    {
                        //m_log.Warn("[J2KIMAGE]: RunUpdate() called with missing asset data (no missing image texture?). Canceling texture transfer");
                        m_currentPacket = m_stopPacket;
                        return;
                    }

                    if (DiscardLevel >= 0 || m_stopPacket == 0)
                    {
                        // This shouldn't happen, but if it does, we really can't proceed
                        if (Layers == null)
                        {
                            m_log.Warn("[J2KIMAGE]: RunUpdate() called with missing Layers. Canceling texture transfer");
                            m_currentPacket = m_stopPacket;
                            return;
                        }

                        int maxDiscardLevel = Math.Max(0, Layers.Length - 1);

                        // Treat initial texture downloads with a DiscardLevel of -1 a request for the highest DiscardLevel
                        if (DiscardLevel < 0 && m_stopPacket == 0)
                        {
                            DiscardLevel = (sbyte)maxDiscardLevel;
                        }

                        // Clamp at the highest discard level
                        DiscardLevel = (sbyte)Math.Min(DiscardLevel, maxDiscardLevel);

                        //Calculate the m_stopPacket
                        if (Layers.Length > 0)
                        {
                            m_stopPacket = (uint)GetPacketForBytePosition(Layers[(Layers.Length - 1) - DiscardLevel].End);
                            //I don't know why, but the viewer seems to expect the final packet if the file
                            //is just one packet bigger.
                            if (TexturePacketCount() == m_stopPacket + 1)
                            {
                                m_stopPacket = TexturePacketCount();
                            }
                        }
                        else
                        {
                            m_stopPacket = TexturePacketCount();
                        }

                        m_currentPacket = StartPacket;
                    }
                }
            }
        }