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

C# Assets.AssetBase类代码示例

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

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



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

示例1: AssetLandmark

 public AssetLandmark(AssetBase a)
     : base(a.ID, a.Name, a.TypeAsset, a.CreatorID)
 {
     Data = a.Data;
     Description = a.Description;
     InternData();
 }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:7,代码来源:AssetLandmark.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.Temporary : 0
                                  };
            asset.ID = m_scene.AssetService.Store(asset);

            return asset.ID;
        }
开发者ID:NanaYngvarrdottir,项目名称:WhiteCore-Dev,代码行数:13,代码来源:Graphics.cs


示例3: FetchTexture

        /// <summary>
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <param name="textureID"></param>
        /// <param name="format"></param>
        /// <param name="response"></param>
        /// <returns>False for "caller try another codec"; true otherwise</returns>
        bool FetchTexture (OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format,
                                  out byte [] response)
        {
            //MainConsole.Instance.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
            AssetBase texture;

            string fullID = textureID.ToString ();
            if (format != DefaultFormat)
                fullID = fullID + "-" + format;

            if (!string.IsNullOrEmpty (REDIRECT_URL)) {
                // Only try to fetch locally cached textures. Misses are redirected
                texture = m_assetService.GetCached (fullID);

                if (texture != null) {
                    if (texture.Type != (sbyte)AssetType.Texture &&        // not actually a texture
                        texture.Type != (sbyte)AssetType.Unknown &&        // .. but valid
                        texture.Type != (sbyte)AssetType.Simstate) {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        response = MainServer.BlankResponse;
                        return true;
                    }

                    response = WriteTextureData (httpRequest, httpResponse, texture, format);
                    return true;
                } else {
                    string textureUrl = REDIRECT_URL + textureID;
                    MainConsole.Instance.Debug ("[AssetCAPS]: Redirecting texture request to " + textureUrl);
                    httpResponse.RedirectLocation = textureUrl;
                    response = MainServer.BlankResponse;
                    return true;
                }
            }

            // no redirect
            // try the cache
            texture = m_assetService.GetCached (fullID);

            if (texture == null) {
                //MainConsole.Instance.DebugFormat("[GETTEXTURE]: texture was not in the cache");

                // Fetch locally or remotely. Misses return a 404
                texture = m_assetService.Get (textureID.ToString ());

                if (texture != null) {
                    if (texture.Type != (sbyte)AssetType.Texture &&
                        texture.Type != (sbyte)AssetType.Unknown &&
                        texture.Type != (sbyte)AssetType.Simstate) {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        response = MainServer.BlankResponse;
                        texture.Dispose ();
                        return true;
                    }

                    if (format == DefaultFormat) {
                        try {
                            response = WriteTextureData (httpRequest, httpResponse, texture, format);
                        } catch {
                            response = MainServer.BlankResponse;
                        }
                        texture.Dispose ();
                        return true;
                    }

                    AssetBase newTexture = new AssetBase (texture.ID + "-" + format, texture.Name, AssetType.Texture,
                                                                     texture.CreatorID) { Data = ConvertTextureData (texture, format) };

                    if (newTexture.Data.Length == 0)            // unable to convert
                    {
                        response = MainServer.BlankResponse;
                        texture.Dispose ();
                        newTexture.Dispose ();
                        return false; // !!! Caller try another codec, please!
                    }

                    newTexture.Flags = AssetFlags.Collectable | AssetFlags.Temporary;
                    newTexture.ID = m_assetService.Store (newTexture);
                    try {
                        response = WriteTextureData (httpRequest, httpResponse, newTexture, format);
                    } catch {
                        response = MainServer.BlankResponse;
                    }
                    newTexture.Dispose ();
                    texture.Dispose ();

                    return true;
                }

                // nothing found... replace with the 'missing_texture" texture
                // try the cache first
                texture = m_assetService.GetCached (Constants.MISSING_TEXTURE_ID);

//.........这里部分代码省略.........
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:101,代码来源:AssetCAPS.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="textureIDs"></param>
        /// <param name="startHeights"></param>
        /// <param name="heightRanges"></param>
        /// <param name="regionPosition"></param>
        /// <param name="assetService"></param>
        /// <param name="textureTerrain"></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++)
                    {
                        UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]);
                        AssetBase asset = assetService.Get(cacheID.ToString());
                        if ((asset != null) && (asset.Data != null) && (asset.Data.Length != 0))
                        {
                            try
                            {
                                using (MemoryStream stream = new MemoryStream(asset.Data))
                                    detailTexture[i] = (Bitmap) Image.FromStream(stream);
                            }
                            catch (Exception ex)
                            {
                                MainConsole.Instance.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
                            byte[] assetData = assetService.GetData(textureIDs[i].ToString());
                            if (assetData != null)
                            {
                                try
                                {
                                    detailTexture[i] = (Bitmap) J2kImage.FromBytes(assetData);
                                }
                                catch (Exception ex)
                                {
                                    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 != 256 || bitmap.Height != 256)
                                    bitmap = ImageUtils.ResizeImage(bitmap, 256, 256);

                                // 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"
//.........这里部分代码省略.........
开发者ID:BogusCurry,项目名称:WhiteCore-Dev,代码行数:101,代码来源:TerrainSplat.cs


示例5: PreAssetRequestCallback

        protected void PreAssetRequestCallback(string fetchedAssetID, object assetType, AssetBase fetchedAsset)
        {
            // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer
            if (fetchedAsset != null && fetchedAsset.Type == (sbyte) AssetType.Unknown)
            {
                AssetType type = (AssetType) assetType;
                MainConsole.Instance.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}",
                                                fetchedAsset.ID, type);
                fetchedAsset.Type = (sbyte) type;
            }

            AssetRequestCallback(fetchedAssetID, this, fetchedAsset);
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:13,代码来源:AssetsRequest.cs


示例6: AbuseTextureUploaded

 public void AbuseTextureUploaded(UUID agentID, UUID assetID, byte[] data)
 {
     //MainConsole.Instance.InfoFormat("[AssetCAPS]: Received baked texture {0}", assetID.ToString());
     AssetBase asset = new AssetBase(assetID, "Abuse Texture", AssetType.Texture, agentID) { Data = data };
     asset.ID = m_Scene.AssetService.Store(asset);
     MainConsole.Instance.DebugFormat("[AbuseCAPS]: texture new id {0}", assetID.ToString());
 }
开发者ID:BogusCurry,项目名称:WhiteCore-Dev,代码行数:7,代码来源:AbuseReportsModule.cs


示例7: CreateMapTileAsync

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

            if (terrain == null)
                return;

            byte[] terraindata, mapdata;
            terrain.CreateMapTile(out terraindata, out mapdata);

            if (terraindata != null)
            {
                if (m_scene.RegionInfo.RegionSettings.TerrainMapImageID != UUID.Zero)
                    m_scene.RegionInfo.RegionSettings.TerrainMapImageID =
                        m_scene.AssetService.UpdateContent(m_scene.RegionInfo.RegionSettings.TerrainMapImageID,
                                                           terraindata);
                if (m_scene.RegionInfo.RegionSettings.TerrainMapImageID == UUID.Zero)
                    //Do not optimize away! UpdateContent can fail sometimes!
                {
                    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
                                                 };
                    m_scene.RegionInfo.RegionSettings.TerrainMapImageID = m_scene.AssetService.Store(Terrainasset);
                }
            }

            if (mapdata != null)
            {
                if (m_scene.RegionInfo.RegionSettings.TerrainImageID != UUID.Zero)
                    m_scene.RegionInfo.RegionSettings.TerrainImageID =
                        m_scene.AssetService.UpdateContent(m_scene.RegionInfo.RegionSettings.TerrainImageID, mapdata);
                if (m_scene.RegionInfo.RegionSettings.TerrainImageID == UUID.Zero)
                    //Do not optimize away! UpdateContent can fail sometimes!
                {
                    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
                                             };
                    m_scene.RegionInfo.RegionSettings.TerrainImageID = m_scene.AssetService.Store(Mapasset);
                }
            }

            byte[] overlay = GenerateOverlay();

            if (overlay != null)
            {
                if (m_scene.RegionInfo.RegionSettings.ParcelMapImageID != UUID.Zero)
                    m_scene.RegionInfo.RegionSettings.ParcelMapImageID =
                        m_scene.AssetService.UpdateContent(m_scene.RegionInfo.RegionSettings.ParcelMapImageID, overlay);
                if (m_scene.RegionInfo.RegionSettings.ParcelMapImageID == UUID.Zero)
                    //Do not optimize away! UpdateContent can fail sometimes!
                {
                    AssetBase Parcelasset = new AssetBase(
                        UUID.Random(),
                        "terrainMapImage_" + m_scene.RegionInfo.RegionID,
                        AssetType.Simstate,
                        m_scene.RegionInfo.RegionID)
                                                {
                                                    Data = overlay,
                                                    Description = m_scene.RegionInfo.RegionName,
                                                    Flags =
                                                        AssetFlags.Deletable | AssetFlags.Rewritable |
                                                        AssetFlags.Maptile
                                                };
                    m_scene.RegionInfo.RegionSettings.ParcelMapImageID = m_scene.AssetService.Store(Parcelasset);
                }
            }
            else
                m_scene.RegionInfo.RegionSettings.ParcelMapImageID = UUID.Zero;

            m_scene.RegionInfo.RegionSettings.TerrainMapLastRegenerated = DateTime.Now;

            //Update the grid map
            IGridRegisterModule gridRegModule = m_scene.RequestModuleInterface<IGridRegisterModule>();
            if (gridRegModule != null)
                gridRegModule.UpdateGridRegion(m_scene);

            // clear out... these are all redundant?
            //terraindata = null;
            //mapdata = null;
            //overlay = null;
            //terrain = null;
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:99,代码来源:MapImageModule.cs


示例8: BakedTextureUploaded

 public void BakedTextureUploaded (byte [] data, out UUID newAssetID)
 {
     //MainConsole.Instance.InfoFormat("[AssetCAPS]: Received baked texture {0}", assetID);
     AssetBase asset = new AssetBase (UUID.Random (), "Baked Texture", AssetType.Texture, m_AgentID) { Data = data, Flags = AssetFlags.Deletable | AssetFlags.Temporary };
     newAssetID = asset.ID = m_assetService.Store (asset);
     MainConsole.Instance.DebugFormat ("[AssetCAPS]: Baked texture new id {0}", newAssetID);
 }
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:7,代码来源:AssetCAPS.cs


示例9: Store

        public virtual UUID Store(AssetBase asset)
        {
            if (asset == null)
                return UUID.Zero;

            object remoteValue = DoRemoteByURL("AssetServerURI", asset);
            if (remoteValue != null || m_doRemoteOnly)
            {
                if (remoteValue == null)
                    return UUID.Zero;
                asset.ID = (UUID) remoteValue;
            }
            else
                RedisSetAsset(asset);

            IImprovedAssetCache cache = m_registry.RequestModuleInterface<IImprovedAssetCache>();
            if (doDatabaseCaching && cache != null && asset != null && asset.Data != null && asset.Data.Length != 0)
            {
                cache.Expire(asset.ID.ToString());
                cache.Cache(asset.ID.ToString(), asset);
            }

            return asset != null ? asset.ID : UUID.Zero;
        }
开发者ID:CaseyraeStarfinder,项目名称:WhiteCore-Dev,代码行数:24,代码来源:RedisAssetService.cs


示例10: CreateAsset

        /// <summary>
        ///     Create a new asset data structure.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="assetType"></param>
        /// <param name="data"></param>
        /// <param name="creatorID"></param>
        /// <returns></returns>
        private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, string creatorID)
        {
            AssetBase asset = new AssetBase(UUID.Random(), name, (AssetType) assetType, UUID.Parse(creatorID))
                                  {Description = description, Data = data ?? new byte[1]};

            return asset;
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:16,代码来源:InventoryAccessModule.cs


示例11: Store

 public UUID Store(AssetBase asset)
 {
     StoreAsset(asset);
     return asset.ID;
 }
开发者ID:CaseyraeStarfinder,项目名称:WhiteCore-Dev,代码行数:5,代码来源:LocalAssetMainConnector.cs


示例12: BakeAppearance

        public AvatarAppearance BakeAppearance(UUID agentID, int cof_version)
        {
            AvatarAppearance appearance = m_avatarService.GetAppearance(agentID);
            List<BakeType> pendingBakes = new List<BakeType>();
            InventoryFolderBase cof = m_inventoryService.GetFolderForType(agentID, InventoryType.Unknown, AssetType.CurrentOutfitFolder);
            if (cof.Version < cof_version)
            {
                int i = 0;
                while (i < 10)
                {
                    cof = m_inventoryService.GetFolderForType(agentID, InventoryType.Unknown, AssetType.CurrentOutfitFolder);
                    System.Threading.Thread.Sleep(100);
                    if (cof.Version >= cof_version)
                        break;
                    i++;
                }
            }
            List<InventoryItemBase> items = m_inventoryService.GetFolderItems(agentID, cof.ID);
            foreach (InventoryItemBase itm in items)
                MainConsole.Instance.Warn("[ServerSideAppearance]: Baking " + itm.Name);

            for (int i = 0; i < Textures.Length; i++)
                Textures[i] = new TextureData();

            WearableData alphaWearable = null;
            List<UUID> currentItemIDs = new List<UUID>();
            foreach (InventoryItemBase itm in items)
            {
                if (itm.AssetType == (int)AssetType.Link)
                {
                    UUID assetID = m_inventoryService.GetItemAssetID(agentID, itm.AssetID);
                    if (appearance.Wearables.Any((w) => w.GetItem(assetID) != UUID.Zero))
                    {
                        currentItemIDs.Add(assetID);
                        //if (m_lastInventoryItemIDs.Contains(assetID))
                        //    continue;
                        WearableData wearable = new WearableData();
                        AssetBase asset = m_assetService.Get(assetID.ToString());
                        if (asset != null && asset.TypeAsset != AssetType.Object)
                        {
                            wearable.Asset = new AssetClothing(assetID, asset.Data);
                            if (wearable.Asset.Decode())
                            {
                                wearable.AssetID = assetID;
                                wearable.AssetType = wearable.Asset.AssetType;
                                wearable.WearableType = wearable.Asset.WearableType;
                                wearable.ItemID = itm.AssetID;
                                if (wearable.WearableType == WearableType.Alpha)
                                {
                                    alphaWearable = wearable;
                                    continue;
                                }
                                AppearanceManager.DecodeWearableParams(wearable, ref Textures);
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }
            /*foreach (UUID id in m_lastInventoryItemIDs)
            {
                if (!currentItemIDs.Contains(id))
                {
                    OpenMetaverse.AppearanceManager.WearableData wearable = new OpenMetaverse.AppearanceManager.WearableData();
                    AssetBase asset = m_assetService.Get(id.ToString());
                    if (asset != null && asset.TypeAsset != AssetType.Object)
                    {
                        wearable.Asset = new AssetClothing(id, asset.Data);
                        if (wearable.Asset.Decode())
                        {
                            foreach (KeyValuePair<AvatarTextureIndex, UUID> entry in wearable.Asset.Textures)
                            {
                                int i = (int)entry.Key;

                                Textures[i].Texture = null;
                                Textures[i].TextureID = UUID.Zero;
                            }
                        }
                    }
                }
            }*/
            //m_lastInventoryItemIDs = currentItemIDs;
            for (int i = 0; i < Textures.Length; i++)
            {
                /*if (Textures[i].TextureID == UUID.Zero)
                    continue;
                if (Textures[i].Texture != null)
                    continue;*/
                AssetBase asset = m_assetService.Get(Textures[i].TextureID.ToString());
                if (asset != null)
                {
                    Textures[i].Texture = new AssetTexture(Textures[i].TextureID, asset.Data);
                    Textures[i].Texture.Decode();
                }
            }

            for (int bakedIndex = 0; bakedIndex < AppearanceManager.BAKED_TEXTURE_COUNT; bakedIndex++)
            {
//.........这里部分代码省略.........
开发者ID:BogusCurry,项目名称:WhiteCore-Dev,代码行数:101,代码来源:AgentAppearanceService.cs


示例13: SaveAsAsset

        public virtual UUID SaveAsAsset(List<ISceneEntity> objectGroups, out AssetBase asset)
        {
            Vector3 GroupMiddle = Vector3.Zero;
            string AssetXML = "<groups>";

            if (objectGroups.Count == 1)
            {
                m_scene.WhiteCoreEventManager.FireGenericEventHandler("DeleteToInventory", objectGroups[0]);
                AssetXML = objectGroups[0].ToXml2();
            }
            else
            {
                foreach (ISceneEntity objectGroup in objectGroups)
                {
                    Vector3 inventoryStoredPosition = new Vector3
                        (((objectGroup.AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
                              ? m_scene.RegionInfo.RegionSizeX - 1
                              : objectGroup.AbsolutePosition.X)
                         ,
                         (objectGroup.AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
                             ? m_scene.RegionInfo.RegionSizeY - 1
                             : objectGroup.AbsolutePosition.Y,
                         objectGroup.AbsolutePosition.Z);
                    GroupMiddle += inventoryStoredPosition;
                    Vector3 originalPosition = objectGroup.AbsolutePosition;

                    objectGroup.AbsolutePosition = inventoryStoredPosition;

                    m_scene.WhiteCoreEventManager.FireGenericEventHandler("DeleteToInventory", objectGroup);
                    AssetXML += objectGroup.ToXml2();

                    objectGroup.AbsolutePosition = originalPosition;
                }
                GroupMiddle.X /= objectGroups.Count;
                GroupMiddle.Y /= objectGroups.Count;
                GroupMiddle.Z /= objectGroups.Count;
                AssetXML += "<middle>";
                AssetXML += "<mid>" + GroupMiddle.ToRawString() + "</mid>";
                AssetXML += "</middle>";
                AssetXML += "</groups>";
            }

            asset = CreateAsset(
                objectGroups[0].Name,
                objectGroups[0].RootChild.Description,
                (sbyte) AssetType.Object,
                Utils.StringToBytes(AssetXML),
                objectGroups[0].OwnerID.ToString());
            asset.ID = m_scene.AssetService.Store(asset);
            AssetXML = null;
            return asset.ID;
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:52,代码来源:InventoryAccessModule.cs


示例14: 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 UUID 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 UUID.Zero;
                }

                //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 = SceneEntitySerializer.SceneObjectSerializer.ToOriginalXmlFormat(grp);

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

                m_scene.InventoryService.UpdateAssetIDForItem(itemID, asset.ID);

                // this gets called when the agent logs off!
                //remoteClient.SendInventoryItemCreateUpdate(item, 0);

                return asset.ID;
            }
            return UUID.Zero;
        }
开发者ID:BogusCurry,项目名称:WhiteCore-Dev,代码行数:45,代码来源:AttachmentsModule.cs


示例15: RenderMaterialsPostCap

        public byte[] RenderMaterialsPostCap(string path, Stream request,
            OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            MainConsole.Instance.Debug ("[Materials]: POST cap handler");

            OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml (request);
            OSDMap resp = new OSDMap ();

            OSDMap materialsFromViewer = null;

            OSDArray respArr = new OSDArray ();

            if (req.ContainsKey ("Zipped"))
            {
                OSD osd;

                byte[] inBytes = req ["Zipped"].AsBinary ();

                try
                {
                    osd = ZDecompressBytesToOsd (inBytes);

                    if (osd != null)
                    {
                        if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                        {
                            foreach (OSD elem in (OSDArray)osd)
                            {

                                try
                                {
                                    UUID id = new UUID (elem.AsBinary (), 0);
                                    AssetBase materialAsset = null;
                                    if (m_knownMaterials.ContainsKey (id))
                                    {
                                        MainConsole.Instance.Info ("[Materials]: request for known material ID: " + id);
                                        OSDMap matMap = new OSDMap ();
                                        matMap ["ID"] = elem.AsBinary ();

                                        matMap ["Material"] = m_knownMaterials [id];
                                        respArr.Add (matMap);
                                    } else if ((materialAsset = m_scene.AssetService.Get (id.ToString ())) != null)
                                    {
                                        MainConsole.Instance.Info ("[Materials]: request for stored material ID: " + id);
                                        OSDMap matMap = new OSDMap ();
                                        matMap ["ID"] = elem.AsBinary ();

                                        matMap ["Material"] = OSDParser.DeserializeJson (Encoding.UTF8.GetString (materialAsset.Data));
                                        respArr.Add (matMap);
                                    } else
                                        MainConsole.Instance.Info ("[Materials]: request for UNKNOWN material ID: " + id);
                                } catch (Exception)
                                {
                                    // report something here?
                                    continue;
                                }
                            }
                        } else if (osd is OSDMap) // request to assign a material
                        {
                            materialsFromViewer = osd as OSDMap;

                            if (materialsFromViewer.ContainsKey ("FullMaterialsPerFace"))
                            {
                                OSD matsOsd = materialsFromViewer ["FullMaterialsPerFace"];
                                if (matsOsd is OSDArray)
                                {
                                    OSDArray matsArr = matsOsd as OSDArray;

                                    try
                                    {
                                        foreach (OSDMap matsMap in matsArr)
                                        {
                                            // MainConsole.Instance.Debug("[Materials]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap));

                                            uint matLocalID = 0;
                                            try
                                            {
                                                matLocalID = matsMap ["ID"].AsUInteger ();
                                            } catch (Exception e)
                                            {
                                                MainConsole.Instance.Warn ("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
                                            }
                                            // MainConsole.Instance.Debug("[Materials]: matLocalId: " + matLocalID);

                                            OSDMap mat = null;
                                            if (matsMap.ContainsKey ("Material"))
                                            {
                                                try
                                                {
                                                    mat = matsMap ["Material"] as OSDMap;

                                                } catch (Exception e)
                                                {
                                                    MainConsole.Instance.Warn ("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message);
                                                    continue;
                                                }
                                            }

                                            if (mat == null)
                                                continue;
//.........这里部分代码省略.........
开发者ID:CaseyraeStarfinder,项目名称:WhiteCore-Dev,代码行数:101,代码来源:RenderMaterials.cs


示例16: UploadCompleteHandler

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

            switch (inventoryType) {
            case "sound":
                inType = 1;
                assType = 1;
                break;
            case "animation":
                inType = 19;
                assType = 20;
                break;
            case "snapshot":
                inType = 15;
                assType = 0;
                break;
            case "wearable":
                inType = 18;
                switch (assetType) {
                case "bodypart":
                    assType = 13;
                    break;
                case "clothing":
                    assType = 5;
                    break;
                }
                break;
            case "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> ();
                    foreach (
                            AssetBase textureAsset in
                                texture_list.Select (t => new AssetBase (UUID.Random (), assetName, AssetType.Texture,
                                                                        m_agentID) { Data = t.AsBinary () })) {
                        textureAsset.ID = m_assetService.Store (textureAsset);
                        textures.Add (textureAsset.ID);
                    }

                    InventoryFolderBase meshFolder = m_inventoryService.GetFolderForType (m_agentID, InventoryType.Mesh, FolderType.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)
                                f.OffsetU = offsets;
                            if (offsett != 0)
                                f.OffsetV = offsett;
                            if (scales != 0)
                                f.RepeatU = scales;
                            if (scalet != 0)
                                f.RepeatV = scalet;
                            f.TextureID = textures.Count > textureNum
//.........这里部分代码省略.........
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:101,代码来源:InventoryCAPS.cs


示例17: WriteTextureData

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Inventory.InventoryFolderBase类代码示例发布时间:2022-05-26
下一篇:
C# Services.GridRegion类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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