LIBOMV-505 Merge in jradford-texturepipeline branch

This changes the way texture requests are handled, the AssetManager
RequestImage method signatures have been changed and are now expecting
the callback with the request.
Progressive requests for textures are supported for rendering viewers
Tuning parameters have been moved to Settings


git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2699 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
Jim Radford
2009-05-07 16:10:52 +00:00
parent 2725f1b660
commit 14869cab48
11 changed files with 883 additions and 759 deletions

View File

@@ -9,8 +9,8 @@ namespace OpenMetaverse.TestClient
{
UUID TextureID;
AutoResetEvent DownloadHandle = new AutoResetEvent(false);
ImageDownload Image;
AssetTexture Asset;
TextureRequestState resultState;
public DownloadTextureCommand(TestClient testClient)
{
@@ -19,8 +19,6 @@ namespace OpenMetaverse.TestClient
"Usage: downloadtexture [texture-uuid] [discardlevel]";
Category = CommandCategory.Inventory;
testClient.Assets.OnImageReceiveProgress += new AssetManager.ImageReceiveProgressCallback(Assets_OnImageReceiveProgress);
testClient.Assets.OnImageReceived += new AssetManager.ImageReceivedCallback(Assets_OnImageReceived);
}
public override string Execute(string[] args, UUID fromAgentID)
@@ -30,7 +28,6 @@ namespace OpenMetaverse.TestClient
TextureID = UUID.Zero;
DownloadHandle.Reset();
Image = null;
Asset = null;
if (UUID.TryParse(args[0], out TextureID))
@@ -43,31 +40,31 @@ namespace OpenMetaverse.TestClient
return "Usage: downloadtexture [texture-uuid] [discardlevel]";
}
Client.Assets.RequestImage(TextureID, ImageType.Normal, 1000000.0f, discardLevel, 0);
Client.Assets.RequestImage(TextureID, ImageType.Normal, Assets_OnImageReceived);
if (DownloadHandle.WaitOne(120 * 1000, false))
{
if (Image != null && Image.Success)
if (resultState == TextureRequestState.Finished)
{
if (Asset != null && Asset.Decode())
{
try { File.WriteAllBytes(Image.ID.ToString() + ".jp2", Asset.AssetData); }
try { File.WriteAllBytes(Asset.AssetID + ".jp2", Asset.AssetData); }
catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); }
return String.Format("Saved {0}.jp2 ({1}x{2})", Image.ID, Asset.Image.Width, Asset.Image.Height);
return String.Format("Saved {0}.jp2 ({1}x{2})", Asset.AssetID, Asset.Image.Width, Asset.Image.Height);
}
else
{
return "Failed to decode texture " + TextureID.ToString();
}
}
else if (Image != null && Image.NotFound)
else if (resultState == TextureRequestState.NotFound)
{
return "Simulator reported texture not found: " + TextureID.ToString();
}
else
{
return "Download failed for texture " + TextureID.ToString();
return "Download failed for texture " + TextureID + " " + resultState;
}
}
else
@@ -81,18 +78,12 @@ namespace OpenMetaverse.TestClient
}
}
private void Assets_OnImageReceived(ImageDownload image, AssetTexture asset)
private void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset)
{
Image = image;
resultState = state;
Asset = asset;
DownloadHandle.Set();
}
private void Assets_OnImageReceiveProgress(UUID image, int lastPacket, int recieved, int total)
{
if (image == TextureID)
Console.WriteLine(String.Format("Texture {0}: Received {1} / {2} (Packet: {3})", image, recieved, total, lastPacket));
}
}
}