• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Framework.AssetBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Aurora.Framework.AssetBase的典型用法代码示例。如果您正苦于以下问题:C# AssetBase类的具体用法?C# AssetBase怎么用?C# AssetBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AssetBase类属于Aurora.Framework命名空间,在下文中一共展示了AssetBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StoreAsset

 public bool StoreAsset(AssetBase asset)
 {
     try
     {
         if (asset.Name.Length > 64)
             asset.Name = asset.Name.Substring(0, 64);
         if (asset.Description.Length > 128)
             asset.Description = asset.Description.Substring(0, 128);
         if (ExistsAsset(asset.ID))
         {
             AssetBase oldAsset = GetAsset(asset.ID);
             if (oldAsset == null || (oldAsset.Flags & AssetFlags.Rewritable) == AssetFlags.Rewritable)
             {
                 MainConsole.Instance.Debug("[LocalAssetDatabase]: Asset already exists in the db, overwriting - " + asset.ID);
                 Delete(asset.ID, true);
                 InsertAsset(asset, asset.ID);
             }
             else
             {
                 MainConsole.Instance.Debug("[LocalAssetDatabase]: Asset already exists in the db, fixing ID... - " + asset.ID);
                 InsertAsset(asset, UUID.Random());
             }
         }
         else
         {
             InsertAsset(asset, asset.ID);
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.ErrorFormat("[LocalAssetDatabase]: Failure creating asset {0} with name \"{1}\". Error: {2}",
                           asset.ID, asset.Name, e);
     }
     return true;
 }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:35,代码来源:LocalAssetMainConnector.cs


示例2: SaveBitmap

        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;
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:14,代码来源:Graphics.cs


示例3: Handle

        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.High))
                    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());
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:22,代码来源:AssetServerPostHandler.cs


示例4: HandleLinkInventoryItem

        /// <summary>
        /// Create a new 'link' to another inventory item
        /// Used in Viewer 2 for appearance.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="transActionID"></param>
        /// <param name="folderID"></param>
        /// <param name="callbackID"></param>
        /// <param name="description"></param>
        /// <param name="name"></param>
        /// <param name="invType"></param>
        /// <param name="type"></param>
        /// <param name="olditemID"></param>
        protected void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID,
                                             uint callbackID, string description, string name,
                                             sbyte invType, sbyte type, UUID olditemID)
        {
            //MainConsole.Instance.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID);

            if (!m_scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
                return;

            IScenePresence presence;
            if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
            {
                if (olditemID == AvatarWearable.DEFAULT_EYES_ITEM ||
                            olditemID == AvatarWearable.DEFAULT_BODY_ITEM ||
                            olditemID == AvatarWearable.DEFAULT_HAIR_ITEM ||
                            olditemID == AvatarWearable.DEFAULT_PANTS_ITEM ||
                            olditemID == AvatarWearable.DEFAULT_SHIRT_ITEM ||
                            olditemID == AvatarWearable.DEFAULT_SKIN_ITEM)
                {
                    return;
                }
                AssetBase asset = new AssetBase {ID = olditemID, Type = type, Name = name, Description = description};

                CreateNewInventoryItem(
                    remoteClient, remoteClient.AgentId.ToString(), "", folderID, name, 0, callbackID, asset, invType,
                    (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
                    (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
            }
            else
            {
                MainConsole.Instance.ErrorFormat(
                    "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem",
                    remoteClient.AgentId);
            }
        }
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:48,代码来源:LLClientInventory.cs


示例5: CreateNewInventoryItem

 /// <summary>
 /// Create a new Inventory Item
 /// </summary>
 /// <param name="remoteClient"></param>
 /// <param name="creatorData"></param>
 /// <param name="folderID"></param>
 /// <param name="flags"></param>
 /// <param name="callbackID"></param>
 /// <param name="asset"></param>
 /// <param name="invType"></param>
 /// <param name="everyoneMask"></param>
 /// <param name="nextOwnerMask"></param>
 /// <param name="groupMask"></param>
 /// <param name="creationDate"></param>
 /// <param name="creatorID"></param>
 /// <param name="name"></param>
 /// <param name="baseMask"></param>
 /// <param name="currentMask"></param>
 protected void CreateNewInventoryItem(
     IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType,
     uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
 {
     InventoryItemBase item = new InventoryItemBase
                                  {
                                      Owner = remoteClient.AgentId,
                                      CreatorId = creatorID,
                                      CreatorData = creatorData,
                                      ID = UUID.Random(),
                                      AssetID = asset.ID,
                                      Description = asset.Description,
                                      Name = name,
                                      Flags = flags,
                                      AssetType = asset.Type,
                                      InvType = invType,
                                      Folder = folderID,
                                      CurrentPermissions = currentMask,
                                      NextPermissions = nextOwnerMask,
                                      EveryOnePermissions = everyoneMask,
                                      GroupPermissions = groupMask,
                                      BasePermissions = baseMask,
                                      CreationDate = creationDate
                                  };
     m_scene.InventoryService.AddItemAsync(item, (itm) =>
     {
         IAvatarFactory avFactory = m_scene.RequestModuleInterface<IAvatarFactory>();
         if (avFactory != null)
             avFactory.NewAppearanceLink(itm);
         remoteClient.SendInventoryItemCreateUpdate(itm, callbackID);
     });
 }
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:50,代码来源:LLClientInventory.cs


示例6: UploadCompleteHandler

        ///<summary>
        ///</summary>
        ///<param name = "assetID"></param>
        ///<param name = "inventoryItem"></param>
        ///<param name = "data"></param>
        public UUID UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
                                          UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
                                          string assetType, uint everyone_mask, uint group_mask, uint next_owner_mask)
        {
            sbyte assType = 0;
            sbyte inType = 0;

            if (inventoryType == "sound")
            {
                inType = 1;
                assType = 1;
            }
            else if (inventoryType == "animation")
            {
                inType = 19;
                assType = 20;
            }
            else if (inventoryType == "snapshot")
            {
                inType = 15;
                assType = 0;
            }
            else if (inventoryType == "wearable")
            {
                inType = 18;
                switch (assetType)
                {
                    case "bodypart":
                        assType = 13;
                        break;
                    case "clothing":
                        assType = 5;
                        break;
                }
            }
            else if (inventoryType == "object")
            {
                inType = (sbyte) InventoryType.Object;
                assType = (sbyte) AssetType.Object;

                List<Vector3> positions = new List<Vector3>();
                List<Quaternion> rotations = new List<Quaternion>();
                OSDMap request = (OSDMap) OSDParser.DeserializeLLSDXml(data);
                OSDArray instance_list = (OSDArray) request["instance_list"];
                OSDArray mesh_list = (OSDArray) request["mesh_list"];
                OSDArray texture_list = (OSDArray) request["texture_list"];
                SceneObjectGroup grp = null;

                List<UUID> textures = new List<UUID>();
#if(!ISWIN)
                for (int i = 0; i < texture_list.Count; i++)
                {
                    AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, AssetType.Texture, m_service.AgentID);
                    textureAsset.Data = texture_list[i].AsBinary();
                    textureAsset.ID = m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.ID);
                }
#else
                foreach (AssetBase textureAsset in texture_list.Select(t => new AssetBase(UUID.Random(), assetName, AssetType.Texture,
                                                                                          m_service.AgentID) {Data = t.AsBinary()}))
                {
                    textureAsset.ID = m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.ID);
                }
#endif
                InventoryFolderBase meshFolder = m_inventoryService.GetFolderForType(m_service.AgentID,
                                                                                     InventoryType.Mesh, AssetType.Mesh);
                for (int i = 0; i < mesh_list.Count; i++)
                {
                    PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

                    Primitive.TextureEntry textureEntry =
                        new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
                    OSDMap inner_instance_list = (OSDMap) instance_list[i];

                    OSDArray face_list = (OSDArray) inner_instance_list["face_list"];
                    for (uint face = 0; face < face_list.Count; face++)
                    {
                        OSDMap faceMap = (OSDMap) face_list[(int) face];
                        Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
                        if (faceMap.ContainsKey("fullbright"))
                            f.Fullbright = faceMap["fullbright"].AsBoolean();
                        if (faceMap.ContainsKey("diffuse_color"))
                            f.RGBA = faceMap["diffuse_color"].AsColor4();

                        int textureNum = faceMap["image"].AsInteger();
                        float imagerot = faceMap["imagerot"].AsInteger();
                        float offsets = (float) faceMap["offsets"].AsReal();
                        float offsett = (float) faceMap["offsett"].AsReal();
                        float scales = (float) faceMap["scales"].AsReal();
                        float scalet = (float) faceMap["scalet"].AsReal();

                        if (imagerot != 0)
                            f.Rotation = imagerot;
                        if (offsets != 0)
//.........这里部分代码省略.........
开发者ID:rjspence,项目名称:YourSim,代码行数:101,代码来源:InventoryCAPS.cs


示例7: Store

 public UUID Store(AssetBase asset)
 {
     UUID retVal = m_localService.Store(asset);
     return retVal;
 }
开发者ID:JAllard,项目名称:Aurora-Sim,代码行数:5,代码来源:IWCAssetConnector.cs


示例8: AdjustIdentifiers

 /*protected override void FixAssetID (ref AssetBase asset)
 {
     if (asset == null || asset.Metadata.URL != "")//Don't reappend
         return;
     asset.URL = MainServer.Instance.FullHostName + ":" + MainServer.Instance.Port + "/assets/" + asset.ID;
     //asset.ID = MainServer.Instance.FullHostName + ":" + MainServer.Instance.Port + "/assets/" + asset.ID;
 }*/
 protected void AdjustIdentifiers(AssetBase meta)
 {
     /*if (meta.CreatorID != null && meta.CreatorID != UUID.Zero)
     {
         UserAccount creator = m_UserAccountService.GetUserAccount (UUID.Zero, uuid);
         if (creator != null)
             meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
     }*/
 }
开发者ID:JAllard,项目名称:HyperGrid,代码行数:16,代码来源:HGAssetService.cs


示例9: Cache

        /// <summary>
        ///   Cache asset.
        /// </summary>
        /// <param name = "asset">
        ///   The asset that is being cached.
        /// </param>
        public void Cache(AssetBase asset)
        {
            if (asset != null)
            {
//                MainConsole.Instance.DebugFormat("[CENOME ASSET CACHE]: Caching asset {0}", asset.IDString);

                long size = asset.Data != null ? asset.Data.Length : 1;
                m_cache.Set(asset.IDString, asset, size);
                m_cachedCount++;
            }
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:17,代码来源:CenomeAssetCache.cs


示例10: AssetDataCallback

        private void AssetDataCallback(UUID AssetID, AssetBase asset)
        {
            HasAsset = true;

            if (asset == null || asset.Data == null || asset.Type == (int)AssetType.Mesh)
            {
                if (m_imageManager.MissingImage != null)
                {
                    m_asset = m_imageManager.MissingImage.Data;
                }
                else
                {
                    m_asset = null;
                    IsDecoded = true;
                }
            }
            else
            {
                m_asset = asset.Data;
                asset = null;
            }

            RunUpdate();
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:24,代码来源:J2KImage.cs


示例11: CreateDefaultAvatars

        /// <summary>
        /// This method is called if a given model avatar name can not be found. If the external
        /// file has already been loaded once, then control returns immediately. If not, then it
        /// looks for a default appearance file. This file contains XML definitions of zero or more named
        /// avatars, each avatar can specify zero or more "outfits". Each outfit is a collection
        /// of items that together, define a particular ensemble for the avatar. Each avatar should
        /// indicate which outfit is the default, and this outfit will be automatically worn. The
        /// other outfits are provided to allow "real" avatars a way to easily change their outfits.
        /// </summary>

        private bool CreateDefaultAvatars()
        {
            // Only load once
            if (m_defaultAvatarsLoaded)
            {
                return false;
            }

            MainConsole.Instance.DebugFormat("[RADMIN] Creating default avatar entries");

            m_defaultAvatarsLoaded = true;

            // Load processing starts here...

            try
            {
                string defaultAppearanceFileName = null;

                //m_config may be null if RemoteAdmin configuration secition is missing or disabled in Aurora.ini
                if (m_config != null)
                {
                    defaultAppearanceFileName = m_config.GetString("default_appearance", "default_appearance.xml");
                }

                if (File.Exists(defaultAppearanceFileName))
                {
                    XmlDocument doc = new XmlDocument();
                    string name     = "*unknown*";
                    string email    = "[email protected]";
                    uint   regionXLocation     = 1000;
                    uint   regionYLocation     = 1000;
                    string password   = UUID.Random().ToString(); // No requirement to sign-in.
                    UUID ID = UUID.Zero;
                    XmlNode perms = null;

                    IScene scene = manager.CurrentOrFirstScene;
                    IInventoryService inventoryService = scene.InventoryService;
                    IAssetService assetService = scene.AssetService;

                    doc.LoadXml(File.ReadAllText(defaultAppearanceFileName));

                    // Load up any included assets. Duplicates will be ignored
                    XmlNodeList assets = doc.GetElementsByTagName("RequiredAsset");
                    foreach (XmlNode assetNode in assets)
                    {
                        AssetBase asset = new AssetBase(UUID.Random(), GetStringAttribute(assetNode, "name", ""),
                                                        (AssetType)
                                                        SByte.Parse(GetStringAttribute(assetNode, "type", "")),
                                                        UUID.Zero)
                                              {
                                                  Description = GetStringAttribute(assetNode, "desc", ""),
                                                  Data = Convert.FromBase64String(assetNode.InnerText),
                                                  Flags = ((Boolean.Parse(GetStringAttribute(assetNode, "local", "")))
                                                               ? AssetFlags.Local
                                                               : AssetFlags.Normal) |
                                                          ((Boolean.Parse(GetStringAttribute(assetNode, "temporary", "")))
                                                               ? AssetFlags.Temperary
                                                               : AssetFlags.Normal)
                                              };

                        asset.FillHash();
                        asset.ID = assetService.Store(asset);
                    }

                    XmlNodeList avatars = doc.GetElementsByTagName("Avatar");

                    // The document may contain multiple avatars

                    foreach (XmlElement avatar in avatars)
                    {
                        MainConsole.Instance.DebugFormat("[RADMIN] Loading appearance for {0}, gender = {1}",
                            GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?"));

                        // Create the user identified by the avatar entry

                        bool include = false;
                        try
                        {
                            // Only the name value is mandatory
                            name   = GetStringAttribute(avatar,"name",name);
                            email  = GetStringAttribute(avatar,"email",email);
                            regionXLocation   = GetUnsignedAttribute(avatar,"regx",regionXLocation);
                            regionYLocation   = GetUnsignedAttribute(avatar,"regy",regionYLocation);
                            password = GetStringAttribute(avatar,"password",password);

                            string[] names = name.Split();
                            UUID scopeID = scene.RegionInfo.ScopeID;
                            UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, names[0], names[1]);
                            if (null == account)
                            {
//.........这里部分代码省略.........
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:101,代码来源:RemoteAdminPlugin.cs


示例12: WriteAsset

 private void WriteAsset(string id, AssetBase asset, TarArchiveWriter writer)
 {
     if (asset != null)
         writer.WriteFile("assets/" + asset.ID, OSDParser.SerializeJsonString(asset.ToOSD()));
     else
         MainConsole.Instance.WarnFormat("[FileBasedSimulationData]: Could not find asset {0} to save.", id);
 }
开发者ID:rjspence,项目名称:YourSim,代码行数:7,代码来源:FileBasedSimulationData.cs


示例13: UpdateKnownItem

        /// <summary>
        /// Update the attachment asset for the new sog details if they have changed.
        /// </summary>
        /// 
        /// This is essential for preserving attachment attributes such as permission.  Unlike normal scene objects,
        /// these details are not stored on the region.
        /// 
        /// <param name="remoteClient"></param>
        /// <param name="grp"></param>
        /// <param name="itemID"></param>
        /// <param name="agentID"></param>
        protected void UpdateKnownItem (IClientAPI remoteClient, ISceneEntity grp, UUID itemID, UUID agentID)
        {
            if (grp != null)
            {
                if (!grp.HasGroupChanged)
                {
                    //MainConsole.Instance.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
                    return;
                }

                //let things like state saves and another async things be performed before we serialize the object
                grp.BackupPreparation();

                MainConsole.Instance.InfoFormat(
                    "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
                    grp.UUID, grp.GetAttachmentPoint());

                string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat((SceneObjectGroup)grp);

                InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
                item = m_scene.InventoryService.GetItem(item);

                if (item != null)
                {
                    AssetBase asset = new AssetBase(UUID.Random(), grp.Name,
                                                    AssetType.Object, remoteClient.AgentId)
                                          {
                                              Description = grp.RootChild.Description,
                                              Data = Utils.StringToBytes(sceneObjectXml)
                                          };
                    asset.ID = m_scene.AssetService.Store(asset);

                    if (item.Folder == UUID.Zero)
                    {
                        InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType (remoteClient.AgentId, InventoryType.Unknown, AssetType.Object);
                        if (folder == null)
                            return;//Probably a non user (bot)
                        item.Folder = folder.ID;
                    }

                    item.AssetID = asset.ID;
                    item.Description = asset.Description;
                    item.Name = asset.Name;
                    item.AssetType = asset.Type;
                    item.InvType = (int)InventoryType.Object;

                    m_scene.InventoryService.UpdateItem(item);

                    // this gets called when the agent logs off!
                    remoteClient.SendInventoryItemCreateUpdate(item, 0);
                }
                else
                {
                    MainConsole.Instance.Warn("[AttachmentModule]: Could not find inventory item for attachment to update!");
                }
            }
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:68,代码来源:AttachmentsModule.cs


示例14: DataReceived

            /// <summary>
            ///   Called once new texture data has been received for this updater.
            /// </summary>
            public void DataReceived(byte[] data, IScene scene)
            {
                ISceneChildEntity part = scene.GetSceneObjectPart(PrimID);

                if (part == null || data == null || data.Length <= 1)
                {
                    string msg =
                        String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
                    IChatModule chatModule = scene.RequestModuleInterface<IChatModule>();
                    if (chatModule != null)
                        chatModule.SimChat(msg, ChatTypeEnum.Say, 0,
                                           part.ParentEntity.AbsolutePosition, part.Name, part.UUID, false, scene);
                    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, scene);
                    }
                }

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

                AssetBase asset = null;

                if (LastAssetID != UUID.Zero)
                {
                    asset = scene.AssetService.Get(LastAssetID.ToString());
                    asset.Description = String.Format("URL image : {0}", Url);
                    asset.Data = assetData;
                    if ((asset.Flags & AssetFlags.Local) == AssetFlags.Local)
                    {
                        asset.Flags = asset.Flags & ~AssetFlags.Local;
                    }
                    if (((asset.Flags & AssetFlags.Temperary) == AssetFlags.Temperary) != ((Disp & DISP_TEMP) != 0))
                    {
                        if ((Disp & DISP_TEMP) != 0) asset.Flags |= AssetFlags.Temperary;
                        else asset.Flags = asset.Flags & ~AssetFlags.Temperary;
                    }
                    asset.ID = scene.AssetService.Store(asset);
                }
                else
                {
                    // Create a new asset for user
                    asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000),
                                          AssetType.Texture,
                                          scene.RegionInfo.RegionID)
                                {Data = assetData, Description = String.Format("URL image : {0}", Url)};
                    if ((Disp & DISP_TEMP) != 0) asset.Flags = AssetFlags.Temperary;
                    asset.ID = scene.AssetService.Store(asset);
                }

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

                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.ID;
                    }
                    else
                    {
                        try
                        {
                            Primitive.TextureEntryFace texface = tmptex.CreateFace((uint) Face);
                            texface.TextureID = asset.ID;
                            tmptex.FaceTextures[Face] = texface;
                        }
                        catch (Exception)
                        {
//.........这里部分代码省略.........
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:101,代码来源:DynamicTextureModule.cs


示例15: LoadAsset

        /// <summary>
        /// Load an asset
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="data"></param>
        /// <returns>true if asset was successfully loaded, false otherwise</returns>
        private bool LoadAsset(string assetPath, byte[] data)
        {
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
            int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

            if (i == -1)
            {
                MainConsole.Instance.ErrorFormat(
                    "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

                return false;
            }

            string extension = filename.Substring(i);
            string uuid = filename.Remove(filename.Length - extension.Length);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];

                if (assetType == AssetType.Unknown)
                    MainConsole.Instance.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid);

                //MainConsole.Instance.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
                AssetBase asset = new AssetBase(UUID.Parse(uuid), String.Empty, assetType, UUID.Zero)
                                      {Data = data};

                // We're relying on the asset service to do the sensible thing and not store the asset if it already
                // exists.
                if (m_useAsync)
                    lock (AssetsToAdd)
                        AssetsToAdd.Add(asset);
                else
                    asset.ID = m_scene.AssetService.Store(asset);

                /**
                 * Create layers on decode for image assets.  This is likely to significantly increase the time to load archives so
                 * it might be best done when dearchive takes place on a separate thread
                if (asset.Type=AssetType.Texture)
                {
                    IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>();
                    if (cacheLayerDecode != null)
                        cacheLayerDecode.syncdecode(asset.FullID, asset.Data);
                }
                */

                return true;
            }
            MainConsole.Instance.ErrorFormat(
                "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
                assetPath, extension);

            return false;
        }
开发者ID:Gnu32,项目名称:Silverfin,代码行数:62,代码来源:ArchiveReadRequest.cs


示例16: SaveFileCacheForAsset

        private void SaveFileCacheForAsset(UUID AssetId, OpenJPEG.J2KLayerInfo[] Layers)
        {
            if (m_useCache)
                m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10));

            if (m_cache != null)
            {
                string assetID = "j2kCache_" + AssetId.ToString();

                AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, AssetType.Notecard,
                                                           UUID.Zero)
                                                 {Flags = AssetFlags.Local | AssetFlags.Temporary};

                #region Serialize Layer Data

                StringBuilder stringResult = new StringBuilder();
                string strEnd = "\n";
                for (int i = 0; i < Layers.Length; i++)
                {
                    if (i == Layers.Length - 1)
                        strEnd = String.Empty;

                    stringResult.AppendFormat("{0}|{1}|{2}{3}", Layers[i].Start, Layers[i].End,
                                              Layers[i].End - Layers[i].Start, strEnd);
                }

                layerDecodeAsset.Data = Util.UTF8.GetBytes(stringResult.ToString());

                #endregion Serialize Layer Data

                m_cache.Cache(layerDecodeAsset);
            }
        }
开发者ID:Gnu32,项目名称:Silverfin,代码行数:33,代码来源:J2KDecoderModule.cs


示例17: CreateMapTileAsync

        public void CreateMapTileAsync(object worthless)
        {
            IMapImageGenerator terrain = m_scene.RequestModuleInterface<IMapImageGenerator>();

            if (terrain == null)
                return;

            bool changed = false;
            byte[] terraindata, mapdata;
            terrain.CreateMapTile(out terraindata, out mapdata);
            if (terraindata != null)
            {
                UUID newID = UUID.Zero;
                if (m_scene.RegionInfo.RegionSettings.TerrainMapImageID != UUID.Zero)
                {
                    m_scene.AssetService.UpdateContent(m_scene.RegionInfo.RegionSettings.TerrainMapImageID, terraindata, out newID);
                    m_scene.RegionInfo.RegionSettings.TerrainMapImageID = newID;
                    changed = true;
                }

                if (m_scene.RegionInfo.RegionSettings.TerrainMapImageID == UUID.Zero)
                {
                    AssetBase Terrainasset = new AssetBase(
                        UUID.Random(),
                        "terrainMapImage_" + m_scene.RegionInfo.RegionID.ToString(),
                        AssetType.Simstate,
                        m_scene.RegionInfo.RegionID)
                    {
                        Data = terraindata,
                        Description = m_scene.RegionInfo.RegionName,
                        Flags = AssetFlags.Deletable | AssetFlags.Rewritable | AssetFlags.Maptile
                    };
                    newID = m_scene.AssetService.Store(Terrainasset);
                }

                if (m_scene.RegionInfo.RegionSettings.TerrainMapImageID != newID)
                {
                    m_scene.RegionInfo.RegionSettings.TerrainMapImageID = newID;
                    changed = true;
                }
            }

            if (mapdata != null)
            {
                UUID newID = UUID.Zero;
                if (m_scene.RegionInfo.RegionSettings.TerrainImageID != UUID.Zero)
                {
                    m_scene.AssetService.UpdateContent(m_scene.RegionInfo.RegionSettings.TerrainImageID, mapdata, out newID);
                    m_scene.RegionInfo.RegionSettings.TerrainImageID = newID;
                    changed = true;
                }

                if (m_scene.RegionInfo.RegionSettings.TerrainImageID == UUID.Zero)
                {
                    AssetBase Mapasset = new AssetBase(
                        UUID.Random(),
                        "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(),
                        AssetType.Simstate,
                        m_scene.RegionInfo.RegionID)
                    {
                        Data = mapdata,
                        Description = m_scene.RegionInfo.RegionName,
                        Flags = AssetFlags.Deletable | AssetFlags.Rewritable | AssetFlags.Maptile
                    };
                    newID = m_scene.AssetService.Store(Mapasset);
                }

                if (m_scene.RegionInfo.RegionSettings.TerrainImageID != newID)
                {
                    m_scene.RegionInfo.RegionSettings.TerrainImageID = newID;
                    changed = true;
                }
            }

            if (changed)//Make sure to update the db with the new settings
                m_scene.RegionInfo.RegionSettings.Save();

            //Update the grid map
            IGridRegisterModule gridRegModule = m_scene.RequestModuleInterface<IGridRegisterModule>();
            if (gridRegModule != null)
                gridRegModule.UpdateGridRegion(m_scene);
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:82,代码来源:WorldMap.cs


示例18: AssetReceived

        private void AssetReceived(string id, Object sender, AssetBase asset)
        {
            UUID assetID = UUID.Zero;
            if (asset != null)
                assetID = asset.ID;
            else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule))
            {
                // Unfortunately we need this here, there's no other way.
                // This is due to the fact that textures opened directly from the agent's inventory
                // don't have any distinguishing feature. As such, in order to serve those when the
                // foreign user is visiting, we need to try again after the first fail to the local
                // asset service.
                string assetServerURL = string.Empty;
                if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL))
                {
                    MainConsole.Instance.DebugFormat(
                        "[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id);
                    AssetService.Get(assetServerURL + "/" + id, InventoryAccessModule, AssetReceived);
                    return;
                }
            }

             

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Framework.Classified类代码示例发布时间:2022-05-24
下一篇:
C# Framework.AgentCircuitData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap