本文整理汇总了C#中Aurora.Framework.AssetBase.FillHash方法的典型用法代码示例。如果您正苦于以下问题:C# AssetBase.FillHash方法的具体用法?C# AssetBase.FillHash怎么用?C# AssetBase.FillHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aurora.Framework.AssetBase
的用法示例。
在下文中一共展示了AssetBase.FillHash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: AvatarIsWearing
/// <summary>
/// Update what the avatar is wearing using an item from their inventory.
/// </summary>
/// <param name = "client"></param>
/// <param name = "e"></param>
public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
{
IScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
MainConsole.Instance.WarnFormat("[AvatarFactory]: AvatarIsWearing unable to find presence for {0}", client.AgentId);
return;
}
MainConsole.Instance.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())
{
InvType = (int) InventoryType.Wearable,
AssetType = (int) AssetType.Clothing,
Name = "Default Underpants",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
Owner = client.AgentId,
CurrentPermissions = 0,
CreatorId = UUID.Zero.ToString(),
AssetID = module.DefaultUnderpants
};
//Locked
client.SendInventoryItemCreateUpdate(item, 0);
}
else if (wear.Type == 10 & wear.ItemID == UUID.Zero)
{
NeedsRebake = true;
InventoryItemBase item = new InventoryItemBase(UUID.Random())
{
InvType = (int) InventoryType.Wearable,
AssetType = (int) AssetType.Clothing,
Name = "Default Underpants",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
Owner = client.AgentId,
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())
{
InvType = (int) InventoryType.Wearable,
AssetType = (int) AssetType.Clothing,
Name = "Default Undershirt",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
Owner = client.AgentId,
CurrentPermissions = 0,
//.........这里部分代码省略.........
示例3: osMakeNotecard
// This needs ThreatLevel high. It is an excellent griefer tool,
// In a loop, it can cause asset bloat and DOS levels of asset
// writes.
//
public void osMakeNotecard(string notecardName, LSL_List contents)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osMakeNotecard", m_host, "OSSL", m_itemID))
return;
// Create new asset
AssetBase asset = new AssetBase(UUID.Random(), notecardName, AssetType.Notecard, m_host.OwnerID) { Description = "Script Generated Notecard" };
string notecardData = String.Empty;
for (int i = 0; i < contents.Length; i++)
{
notecardData += contents.GetLSLStringItem(i) + "\n";
}
int textLength = notecardData.Length;
notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
+ textLength.ToString(CultureInfo.InvariantCulture) + "\n" + notecardData + "}\n";
asset.Data = Util.UTF8.GetBytes(notecardData);
asset.FillHash();
asset.ID = World.AssetService.Store(asset);
// Create Task Entry
TaskInventoryItem taskItem = new TaskInventoryItem();
taskItem.ResetIDs(m_host.UUID);
taskItem.ParentID = m_host.UUID;
taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
taskItem.Name = asset.Name;
taskItem.Description = asset.Description;
taskItem.Type = (int)AssetType.Notecard;
taskItem.InvType = (int)InventoryType.Notecard;
taskItem.OwnerID = m_host.OwnerID;
taskItem.CreatorID = m_host.OwnerID;
taskItem.BasePermissions = (uint)PermissionMask.All;
taskItem.CurrentPermissions = (uint)PermissionMask.All;
taskItem.EveryonePermissions = 0;
taskItem.NextPermissions = (uint)PermissionMask.All;
taskItem.GroupID = m_host.GroupID;
taskItem.GroupPermissions = 0;
taskItem.Flags = 0;
taskItem.SalePrice = 0;
taskItem.SaleType = 0;
taskItem.PermsGranter = UUID.Zero;
taskItem.PermsMask = 0;
taskItem.AssetID = asset.ID;
m_host.Inventory.AddInventoryItem(taskItem, false);
}
示例4: 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)
{
//.........这里部分代码省略.........
示例5: 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++)
{
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
asset = assetService.Get(textureIDs[i].ToString());
if (asset != null)
{
try
{
detailTexture[i] = (Bitmap) J2kImage.FromBytes(asset.Data);
}
catch (Exception ex)
{
MainConsole.Instance.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 (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.FillHash();
newAsset.ID = assetService.Store(newAsset);
}
}
}
//.........这里部分代码省略.........