* Big cleanup of group functions, moving things from MainAvatar to GroupManager, renaming BeginGet* to Request*, and adding new functions and callbacks * Added an Autopilot function that takes doubles as input (very accurate autopilot) * Added Settings.CONTINUOUS_AGENT_UPDATES which defaults to true * Added quotes to the post-build event in VS2005 * Added empty AssetSound and AssetClothing, feel free to fill them in :-) * Client.Self.*Name are read only properties now git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1357 52acb1d6-8a22-11de-b505-999d5b087335
108 lines
4.1 KiB
C#
108 lines
4.1 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using libsecondlife;
|
|
|
|
namespace libsecondlife.TestClient
|
|
{
|
|
public class DumpOutfitCommand : Command
|
|
{
|
|
List<LLUUID> OutfitAssets = new List<LLUUID>();
|
|
AssetManager.ImageReceivedCallback ImageReceivedHandler;
|
|
|
|
public DumpOutfitCommand(TestClient testClient)
|
|
{
|
|
Name = "dumpoutfit";
|
|
Description = "Dumps all of the textures from an avatars outfit to the hard drive. Usage: dumpoutfit [avatar-uuid]";
|
|
ImageReceivedHandler = new AssetManager.ImageReceivedCallback(Assets_OnImageReceived);
|
|
}
|
|
|
|
public override string Execute(string[] args, LLUUID fromAgentID)
|
|
{
|
|
if (args.Length != 1)
|
|
return "Usage: dumpoutfit [avatar-uuid]";
|
|
|
|
LLUUID target;
|
|
|
|
if (!LLUUID.TryParse(args[0], out target))
|
|
return "Usage: dumpoutfit [avatar-uuid]";
|
|
|
|
lock (Client.AvatarList)
|
|
{
|
|
foreach (Avatar avatar in Client.AvatarList.Values)
|
|
{
|
|
if (avatar.ID == target)
|
|
{
|
|
StringBuilder output = new StringBuilder("Downloading ");
|
|
|
|
lock (OutfitAssets) OutfitAssets.Clear();
|
|
Client.Assets.OnImageReceived += ImageReceivedHandler;
|
|
|
|
foreach (KeyValuePair<uint, LLObject.TextureEntryFace> face in avatar.Textures.FaceTextures)
|
|
{
|
|
ImageType type = ImageType.Normal;
|
|
|
|
switch ((AppearanceManager.TextureIndex)face.Key)
|
|
{
|
|
case AppearanceManager.TextureIndex.HeadBaked:
|
|
case AppearanceManager.TextureIndex.EyesBaked:
|
|
case AppearanceManager.TextureIndex.UpperBaked:
|
|
case AppearanceManager.TextureIndex.LowerBaked:
|
|
case AppearanceManager.TextureIndex.SkirtBaked:
|
|
type = ImageType.Baked;
|
|
break;
|
|
}
|
|
|
|
OutfitAssets.Add(face.Value.TextureID);
|
|
Client.Assets.RequestImage(face.Value.TextureID, type, 100000.0f, 0);
|
|
|
|
output.Append(((AppearanceManager.TextureIndex)face.Key).ToString());
|
|
output.Append(" ");
|
|
}
|
|
|
|
return output.ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
return "Couldn't find avatar " + target.ToStringHyphenated();
|
|
}
|
|
|
|
private void Assets_OnImageReceived(ImageDownload image)
|
|
{
|
|
lock (OutfitAssets)
|
|
{
|
|
if (OutfitAssets.Contains(image.ID))
|
|
{
|
|
if (image.Success)
|
|
{
|
|
try
|
|
{
|
|
File.WriteAllBytes(image.ID.ToStringHyphenated() + ".jp2", image.AssetData);
|
|
Console.WriteLine("Wrote JPEG2000 image " + image.ID.ToStringHyphenated() + ".jp2");
|
|
|
|
byte[] tgaFile = OpenJPEGNet.OpenJPEG.DecodeToTGA(image.AssetData);
|
|
File.WriteAllBytes(image.ID.ToStringHyphenated() + ".tga", tgaFile);
|
|
Console.WriteLine("Wrote TGA image " + image.ID.ToStringHyphenated() + ".tga");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Failed to download image " + image.ID.ToStringHyphenated());
|
|
}
|
|
|
|
OutfitAssets.Remove(image.ID);
|
|
|
|
if (OutfitAssets.Count == 0)
|
|
Client.Assets.OnImageReceived -= ImageReceivedHandler;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|