当前位置: 首页>>代码示例>>C#>>正文


C# IAssetService.Store方法代码示例

本文整理汇总了C#中IAssetService.Store方法的典型用法代码示例。如果您正苦于以下问题:C# IAssetService.Store方法的具体用法?C# IAssetService.Store怎么用?C# IAssetService.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAssetService的用法示例。


在下文中一共展示了IAssetService.Store方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddNotecard

        /// <summary>
        /// Add a notecard item to the given part.
        /// </summary>
        /// <param name="assetService"></param>
        /// <param name="part"></param>
        /// <param name="itemName"></param>
        /// <param name="itemID"></param>
        /// <param name="assetID"></param>
        /// <param name="text">The tex to put in the notecard.</param>
        /// <returns>The item that was added</returns>
        public static TaskInventoryItem AddNotecard(
            IAssetService assetService, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text)
        {
            AssetNotecard nc = new AssetNotecard();
            nc.BodyText = text;
            nc.Encode();

            AssetBase ncAsset
                = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero);
            assetService.Store(ncAsset);

            TaskInventoryItem ncItem 
                = new TaskInventoryItem 
                    { Name = itemName, AssetID = assetID, ItemID = itemID,
                      Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
            part.Inventory.AddInventoryItem(ncItem, true); 
            
            return ncItem;
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:29,代码来源:TaskInventoryHelpers.cs

示例2: Splat


//.........这里部分代码省略.........
                                    MainConsole.Instance.Warn("Failed to decode terrain texture " + textureIDs[i] + ": " +
                                                              ex.Message);
                                }
                            }

                            if (detailTexture[i] != null)
                            {
                                Bitmap bitmap = detailTexture[i];

                                // Make sure this texture is the correct size, otherwise resize
                                if (bitmap.Width != outWidth || bitmap.Height != outHeight)
                                    bitmap = ImageUtils.ResizeImage(bitmap, outWidth, outHeight);

                                // Save the decoded and resized texture to the cache
                                byte[] data;
                                using (MemoryStream stream = new MemoryStream())
                                {
                                    bitmap.Save(stream, ImageFormat.Png);
                                    data = stream.ToArray();
                                }

                                // Cache a PNG copy of this terrain texture
                                AssetBase newAsset = new AssetBase
                                                         {
                                                             Data = data,
                                                             Description = "PNG",
                                                             Flags =
                                                                 AssetFlags.Collectable | AssetFlags.Temporary |
                                                                 AssetFlags.Local,
                                                             ID = cacheID,
                                                             Name = String.Empty,
                                                             TypeString = "image/png"
                                                         };
                                newAsset.ID = assetService.Store(newAsset);
                            }
                        }
                    }
                }

                #endregion Texture Fetching
            }

            // Fill in any missing textures with a solid color
            for (int i = 0; i < 4; i++)
            {
                if (detailTexture[i] == null)
                {
                    // Create a solid color texture for this layer
                    detailTexture[i] = new Bitmap(outWidth, outHeight, PixelFormat.Format24bppRgb);
                    using (Graphics gfx = Graphics.FromImage(detailTexture[i]))
                    {
                        using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i]))
                            gfx.FillRectangle(brush, 0, 0, outWidth, outHeight);
                    }
                }
                else if (detailTexture[i].Width != outWidth || detailTexture[i].Height != outHeight)
                {
                    detailTexture[i] = ResizeBitmap(detailTexture[i], outWidth, outHeight);
                }
            }

            #region Layer Map

            float diffX = 1.0f;
            float diffY = 1.0f;
            int newRsX = heightmap.Width / (int)diffX;
开发者ID:emperorstarfinder,项目名称:Virtual-Universe,代码行数:67,代码来源:TerrainSplat.cs

示例3: SaveNonBinaryAssets

        private AssetBase SaveNonBinaryAssets(UUID key, AssetBase asset, IAssetService assetService)
        {
            if (!asset.HasBeenSaved)
            {
                string stringData = Utils.BytesToString(asset.Data);
                MatchCollection mc = Regex.Matches(stringData, sPattern);
                bool didChange = false;
                if (mc.Count >= 1)
                {
                    foreach (Match match in mc)
                    {
                        try
                        {
                            UUID thematch = new UUID(match.Value);
                            UUID newvalue = thematch;
                            if ((thematch == UUID.Zero) || (thematch == key)) continue;
                            if (assetNonBinaryCollection.ContainsKey(thematch))
                            {
                                AssetBase subasset = assetNonBinaryCollection[thematch];
                                if (!subasset.HasBeenSaved)
                                    subasset = SaveNonBinaryAssets(thematch, subasset, assetService);
                                newvalue = subasset.ID;
                            }
                            else if (assetBinaryChangeRecord.ContainsKey(thematch))
                                newvalue = assetBinaryChangeRecord[thematch];

                            if (thematch == newvalue) continue;
                            stringData = stringData.Replace(thematch.ToString(), newvalue.ToString());
                            didChange = true;
                        }
                        catch { }
                    }
                    if (didChange)
                    {
                        asset.Data = Utils.StringToBytes(stringData);
                        // so it doesn't try to find the old file
                        asset.LastHashCode = asset.HashCode;
                    }
                }

                asset.ID = assetService.Store(asset);
                asset.HasBeenSaved = true;
            }
            if (assetNonBinaryCollection.ContainsKey(key))
                assetNonBinaryCollection[key] = asset;
            return asset;
        }
开发者ID:BillyWarrhol,项目名称:Aurora-Sim,代码行数:47,代码来源:InventoryArchiveReadRequest.cs

示例4: AddSceneObject

        /// <summary>
        /// Add a scene object item to the given part.
        /// </summary>
        /// <remarks>
        /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
        /// functions more than once in a test.
        /// </remarks>
        ///
        /// <param name="assetService"></param>
        /// <param name="sop"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="soToAdd"></param>
        /// <param name="soAssetId"></param>
        public static TaskInventoryItem AddSceneObject(
            IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId)
        {
            AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd);
            assetService.Store(taskSceneObjectAsset);
            TaskInventoryItem taskSceneObjectItem
                = new TaskInventoryItem
            { Name = itemName,
                AssetID = taskSceneObjectAsset.FullID,
                ItemID = itemId,
                OwnerID = soToAdd.OwnerID,
                Type = (int)AssetType.Object,
                InvType = (int)InventoryType.Object };
            sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);

            return taskSceneObjectItem;
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:31,代码来源:TaskInventoryHelpers.cs

示例5: AddScript

        /// <summary>
        /// Add a simple script to the given part.
        /// </summary>
        /// <remarks>
        /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather
        /// than a random component.
        /// </remarks>
        /// <param name="assetService"></param>
        /// <param name="part"></param>
        /// <param name="itemId">Item UUID for the script</param>
        /// <param name="assetId">Asset UUID for the script</param>
        /// <param name="scriptName">Name of the script to add</param>
        /// <param name="scriptSource">LSL script source</param>
        /// <returns>The item that was added</returns>
        public static TaskInventoryItem AddScript(
            IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource)
        {
            AssetScriptText ast = new AssetScriptText();
            ast.Source = scriptSource;
            ast.Encode();

            AssetBase asset
                = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero);
            assetService.Store(asset);
            TaskInventoryItem item
                = new TaskInventoryItem 
            { Name = scriptName, AssetID = assetId, ItemID = itemId,
                Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL };
            part.Inventory.AddInventoryItem(item, true);

            return item;
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:32,代码来源:TaskInventoryHelpers.cs

示例6: Splat

        /// <summary>
        /// Builds a composited terrain texture given the region texture
        /// and heightmap settings
        /// </summary>
        /// <param name="heightmap">Terrain heightmap</param>
        /// <param name="regionInfo">Region information including terrain texture parameters</param>
        /// <returns>A composited 256x256 RGB texture ready for rendering</returns>
        /// <remarks>Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting
        /// </remarks>
        public static Bitmap Splat(float[] heightmap, UUID[] textureIDs, float[] startHeights, float[] heightRanges, Vector3d regionPosition, IAssetService assetService, bool textureTerrain)
        {
            Debug.Assert(heightmap.Length == 256 * 256);
            Debug.Assert(textureIDs.Length == 4);
            Debug.Assert(startHeights.Length == 4);
            Debug.Assert(heightRanges.Length == 4);

            Bitmap[] detailTexture = new Bitmap[4];

            if (textureTerrain)
            {
                // Swap empty terrain textureIDs with default IDs
                for (int i = 0; i < textureIDs.Length; i++)
                {
                    if (textureIDs[i] == UUID.Zero)
                        textureIDs[i] = DEFAULT_TERRAIN_DETAIL[i];
                }

                #region Texture Fetching

                if (assetService != null)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        AssetBase asset;
                        UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]);

                        // Try to fetch a cached copy of the decoded/resized version of this texture
                        asset = assetService.GetCached(cacheID.ToString());
                        if (asset != null)
                        {
                            try
                            {
                                using (System.IO.MemoryStream stream = new System.IO.MemoryStream(asset.Data))
                                    detailTexture[i] = (Bitmap)Image.FromStream(stream);
                            }
                            catch (Exception ex)
                            {
                                m_log.Warn("Failed to decode cached terrain texture " + cacheID +
                                    " (textureID: " + textureIDs[i] + "): " + ex.Message);
                            }
                        }

                        if (detailTexture[i] == null)
                        {
                            // Try to fetch the original JPEG2000 texture, resize if needed, and cache as PNG
                            asset = assetService.Get(textureIDs[i].ToString());
                            if (asset != null)
                            {
                                try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); }
                                catch (Exception ex)
                                {
                                    m_log.Warn("Failed to decode terrain texture " + asset.ID + ": " + ex.Message);
                                }
                            }

                            if (detailTexture[i] != null)
                            {
                                Bitmap bitmap = detailTexture[i];

                                // Make sure this texture is the correct size, otherwise resize
                                if (bitmap.Width != 256 || bitmap.Height != 256)
                                    bitmap = ImageUtils.ResizeImage(bitmap, 256, 256);

                                // Save the decoded and resized texture to the cache
                                byte[] data;
                                using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                {
                                    bitmap.Save(stream, ImageFormat.Png);
                                    data = stream.ToArray();
                                }

                                // Cache a PNG copy of this terrain texture
                                AssetBase newAsset = new AssetBase
                                {
                                    Data = data,
                                    Description = "PNG",
                                    Flags = AssetFlags.Collectable,
                                    FullID = cacheID,
                                    ID = cacheID.ToString(),
                                    Local = true,
                                    Name = String.Empty,
                                    Temporary = true,
                                    Type = (sbyte)AssetType.Simstate // Make something up to get around OpenSim's myopic treatment of assets
                                };
                                newAsset.Metadata.ContentType = "image/png";
                                assetService.Store(newAsset);
                            }
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:NickyPerian,项目名称:Aurora,代码行数:101,代码来源:TerrainSplat.cs


注:本文中的IAssetService.Store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。