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


C# AssetBase.FillHash方法代码示例

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


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

示例1: 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:savino1976,项目名称:Aurora-Sim,代码行数:14,代码来源:Graphics.cs

示例2: AvatarIsWearing

        /// <summary>
        /// Update what the avatar is wearing using an item from their inventory.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
        {
            IScenePresence sp = m_scene.GetScenePresence(client.AgentId);
            if (sp == null)
            {
                m_log.WarnFormat("[AvatarFactory]: AvatarIsWearing unable to find presence for {0}", client.AgentId);
                return;
            }

            m_log.DebugFormat("[AvatarFactory]: AvatarIsWearing called for {0}", client.AgentId);

            // operate on a copy of the appearance so we don't have to lock anything
            IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule> ();
            AvatarAppearance avatAppearance = new AvatarAppearance (appearance.Appearance, false);

            IOpenRegionSettingsModule module = m_scene.RequestModuleInterface<IOpenRegionSettingsModule> ();

            bool NeedsRebake = false;
            if (module != null && module.EnableTeenMode)
            {
                foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
                {
                    if (wear.Type == 10 & wear.ItemID == UUID.Zero && module.DefaultUnderpants != UUID.Zero)
                    {
                        NeedsRebake = true;
                        wear.ItemID = module.DefaultUnderpants;
                        InventoryItemBase item = new InventoryItemBase(UUID.Random());
                        item.InvType = (int)InventoryType.Wearable;
                        item.AssetType = (int)AssetType.Clothing;
                        item.Name = "Default Underpants";
                        item.Folder = m_scene.InventoryService.GetFolderForType(client.AgentId, InventoryType.Wearable, AssetType.Clothing).ID;
                        item.Owner = client.AgentId;
                        item.CurrentPermissions = 0;//Locked
                        item.CreatorId = UUID.Zero.ToString();
                        item.AssetID = module.DefaultUnderpants;
                        client.SendInventoryItemCreateUpdate(item, 0);
                    }
                    else if (wear.Type == 10 & wear.ItemID == UUID.Zero)
                    {
                        NeedsRebake = true;
                        InventoryItemBase item = new InventoryItemBase (UUID.Random ());
                        item.InvType = (int)InventoryType.Wearable;
                        item.AssetType = (int)AssetType.Clothing;
                        item.Name = "Default Underpants";
                        item.Folder = m_scene.InventoryService.GetFolderForType (client.AgentId, InventoryType.Wearable, AssetType.Clothing).ID;
                        item.Owner = client.AgentId;
                        item.CurrentPermissions = 0;//Locked
                        if (m_underPantsUUID == UUID.Zero)
                        {
                            m_underPantsUUID = UUID.Random ();
                            AssetBase asset = new AssetBase(m_underPantsUUID, "Default Underpants", AssetType.Clothing,
                                                            UUID.Zero) {Data = Utils.StringToBytes(m_defaultUnderPants)};
                            asset.FillHash();
                            asset.ID = m_scene.AssetService.Store(asset);
                            m_underPantsUUID = asset.ID;
                        }
                        item.CreatorId = UUID.Zero.ToString ();
                        item.AssetID = m_underPantsUUID;
                        m_scene.InventoryService.AddItem(item);
                        client.SendInventoryItemCreateUpdate(item, 0);
                        wear.ItemID = item.ID;
                    }
                    if (wear.Type == 11 && wear.ItemID == UUID.Zero && module.DefaultUndershirt != UUID.Zero)
                    {
                        NeedsRebake = true;
                        wear.ItemID = module.DefaultUndershirt;
                        InventoryItemBase item = new InventoryItemBase(UUID.Random());
                        item.InvType = (int)InventoryType.Wearable;
                        item.AssetType = (int)AssetType.Clothing;
                        item.Name = "Default Undershirt";
                        item.Folder = m_scene.InventoryService.GetFolderForType(client.AgentId, InventoryType.Wearable, AssetType.Clothing).ID;
                        item.Owner = client.AgentId;
                        item.CurrentPermissions = 0;//Locked
                        item.CreatorId = UUID.Zero.ToString();
                        item.AssetID = module.DefaultUndershirt;
                        client.SendInventoryItemCreateUpdate(item, 0);
                    }
                    else if (wear.Type == 11 & wear.ItemID == UUID.Zero)
                    {
                        NeedsRebake = true;
                        InventoryItemBase item = new InventoryItemBase (UUID.Random());
                        item.InvType = (int)InventoryType.Wearable;
                        item.AssetType = (int)AssetType.Clothing;
                        item.Name = "Default Undershirt";
                        item.Folder = m_scene.InventoryService.GetFolderForType (client.AgentId, InventoryType.Wearable, AssetType.Clothing).ID;
                        item.Owner = client.AgentId;
                        item.CurrentPermissions = 0;//Locked
                        if (m_underShirtUUID == UUID.Zero)
                        {
                            m_underShirtUUID = UUID.Random ();
                            AssetBase asset = new AssetBase(m_underShirtUUID, "Default Undershirt", AssetType.Clothing,
                                                            UUID.Zero) {Data = Utils.StringToBytes(m_defaultUnderShirt)};
                            asset.FillHash();
                            asset.ID = m_scene.AssetService.Store(asset);
                            m_underShirtUUID = asset.ID;
//.........这里部分代码省略.........
开发者ID:chazzmac,项目名称:Aurora-Sim,代码行数:101,代码来源:AvatarFactoryModule.cs

示例3: 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;
            }

            m_log.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;
                    AvatarAppearance avatarAppearance;
                    XmlNodeList avatars;
                    XmlNodeList assets;
                    XmlNode perms = null;
                    bool include = false;
                    bool select  = false;

                    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
                    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);
                    }

                    avatars = doc.GetElementsByTagName("Avatar");

                    // The document may contain multiple avatars

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

                        // Create the user identified by the avatar entry

                        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();
//.........这里部分代码省略.........
开发者ID:kchi059,项目名称:Aurora-Sim,代码行数:101,代码来源:RemoteAdminPlugin.cs

示例4: 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(ITerrainChannel heightmap, UUID[] textureIDs, float[] startHeights, float[] heightRanges, Vector3d regionPosition, IAssetService assetService, bool textureTerrain)
        {
            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]);

                        // The asset service does this check as well, so I don't think we need to do this.
                        asset = assetService.GetCached (cacheID.ToString ());
                        if ((asset != null) && (asset.Data != null) && (asset.Data.Length != 0))
                        {
                            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 | AssetFlags.Temperary | AssetFlags.Local,
                                    ID = cacheID,
                                    Name = String.Empty,
                                    TypeString = "image/png"
                                };
                                newAsset.FillHash();
                                newAsset.ID = assetService.Store(newAsset);
                            }
                        }
                    }
                }

//.........这里部分代码省略.........
开发者ID:NickyPerian,项目名称:Aurora-Sim,代码行数:101,代码来源:TerrainSplat.cs


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