diff options
author | gareth | 2007-05-14 03:13:47 +0000 |
---|---|---|
committer | gareth | 2007-05-14 03:13:47 +0000 |
commit | 64a98c736848de6099254f23483058668273c1a5 (patch) | |
tree | a8f2624277e48814531750db0ec07a8d64c1f740 /ExportBot/Commands/DumpOutfitCommand.cs | |
parent | Added skeleton for grid management agent (diff) | |
download | opensim-SC-64a98c736848de6099254f23483058668273c1a5.zip opensim-SC-64a98c736848de6099254f23483058668273c1a5.tar.gz opensim-SC-64a98c736848de6099254f23483058668273c1a5.tar.bz2 opensim-SC-64a98c736848de6099254f23483058668273c1a5.tar.xz |
Finished off adding the new management API to gridserver
Updated VersionInfo.cs finally
Updated prebuild and rebuilt nant build files
Completed Management agent basics
Diffstat (limited to 'ExportBot/Commands/DumpOutfitCommand.cs')
-rw-r--r-- | ExportBot/Commands/DumpOutfitCommand.cs | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/ExportBot/Commands/DumpOutfitCommand.cs b/ExportBot/Commands/DumpOutfitCommand.cs deleted file mode 100644 index 2d3d0d8..0000000 --- a/ExportBot/Commands/DumpOutfitCommand.cs +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.IO; | ||
4 | using System.Collections.Generic; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Utilities.Assets; | ||
7 | using libsecondlife.Utilities.Appearance; | ||
8 | |||
9 | namespace libsecondlife.TestClient | ||
10 | { | ||
11 | public class DumpOutfitCommand : Command | ||
12 | { | ||
13 | libsecondlife.Utilities.Assets.AssetManager Assets; | ||
14 | List<LLUUID> OutfitAssets = new List<LLUUID>(); | ||
15 | |||
16 | public DumpOutfitCommand(TestClient testClient) | ||
17 | { | ||
18 | Name = "dumpoutfit"; | ||
19 | Description = "Dumps all of the textures from an avatars outfit to the hard drive. Usage: dumpoutfit [avatar-uuid]"; | ||
20 | |||
21 | Assets = new AssetManager(testClient); | ||
22 | Assets.OnImageReceived += new AssetManager.ImageReceivedCallback(Assets_OnImageReceived); | ||
23 | } | ||
24 | |||
25 | public override string Execute(string[] args, LLUUID fromAgentID) | ||
26 | { | ||
27 | if (args.Length != 1) | ||
28 | return "Usage: dumpoutfit [avatar-uuid]"; | ||
29 | |||
30 | LLUUID target; | ||
31 | |||
32 | if (!LLUUID.TryParse(args[0], out target)) | ||
33 | return "Usage: dumpoutfit [avatar-uuid]"; | ||
34 | |||
35 | lock (Client.AvatarList) | ||
36 | { | ||
37 | foreach (Avatar avatar in Client.AvatarList.Values) | ||
38 | { | ||
39 | if (avatar.ID == target) | ||
40 | { | ||
41 | StringBuilder output = new StringBuilder("Downloading "); | ||
42 | |||
43 | lock (OutfitAssets) OutfitAssets.Clear(); | ||
44 | |||
45 | foreach (KeyValuePair<uint, LLObject.TextureEntryFace> face in avatar.Textures.FaceTextures) | ||
46 | { | ||
47 | ImageType type = ImageType.Normal; | ||
48 | |||
49 | switch ((AppearanceManager.TextureIndex)face.Key) | ||
50 | { | ||
51 | case AppearanceManager.TextureIndex.HeadBaked: | ||
52 | case AppearanceManager.TextureIndex.EyesBaked: | ||
53 | case AppearanceManager.TextureIndex.UpperBaked: | ||
54 | case AppearanceManager.TextureIndex.LowerBaked: | ||
55 | case AppearanceManager.TextureIndex.SkirtBaked: | ||
56 | type = ImageType.Baked; | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | Assets.RequestImage(face.Value.TextureID, type, 100000.0f, 0); | ||
61 | |||
62 | output.Append(((AppearanceManager.TextureIndex)face.Key).ToString()); | ||
63 | output.Append(" "); | ||
64 | } | ||
65 | |||
66 | return output.ToString(); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | return "Couldn't find avatar " + target.ToStringHyphenated(); | ||
72 | } | ||
73 | |||
74 | private void Assets_OnImageReceived(ImageDownload image) | ||
75 | { | ||
76 | if (image.Success) | ||
77 | { | ||
78 | try | ||
79 | { | ||
80 | File.WriteAllBytes(image.ID.ToStringHyphenated() + ".jp2", image.AssetData); | ||
81 | Console.WriteLine("Wrote JPEG2000 image " + image.ID.ToStringHyphenated() + ".jp2"); | ||
82 | |||
83 | byte[] tgaFile = OpenJPEGNet.OpenJPEG.DecodeToTGA(image.AssetData); | ||
84 | File.WriteAllBytes(image.ID.ToStringHyphenated() + ".tga", tgaFile); | ||
85 | Console.WriteLine("Wrote TGA image " + image.ID.ToStringHyphenated() + ".tga"); | ||
86 | } | ||
87 | catch (Exception e) | ||
88 | { | ||
89 | Console.WriteLine(e.ToString()); | ||
90 | } | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | Console.WriteLine("Failed to download image " + image.ID.ToStringHyphenated()); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | } | ||