本文整理汇总了C#中IAssetService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IAssetService.Get方法的具体用法?C# IAssetService.Get怎么用?C# IAssetService.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAssetService
的用法示例。
在下文中一共展示了IAssetService.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LLImageManager
//Constructor
public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
{
m_imagestore = new Dictionary<UUID,J2KImage>();
m_priorities = new SortedList<double,UUID>();
m_priorityresolver = new Dictionary<int, int>();
m_client = client;
m_assetCache = pAssetCache;
if (pAssetCache != null)
m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f");
else
m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
m_j2kDecodeModule = pJ2kDecodeModule;
}
示例2: 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];
int outWidth = heightmap.Width;
int outHeight = heightmap.Height;
IJ2KDecoder m_imgDecoder;
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)
{
m_imgDecoder = heightmap.Scene.RequestModuleInterface<IJ2KDecoder>();
for (int i = 0; i < 4; i++)
{
UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]);
AssetBase asset = assetService.Get(cacheID.ToString(),false); // ignore warnings here as the cached texture may not exist
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)m_imgDecoder.DecodeToImage(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 != 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",
//.........这里部分代码省略.........
示例3: 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);
}
}
}
}
//.........这里部分代码省略.........