diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/DynamicTextureModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/DynamicTextureModule.cs | 312 |
1 files changed, 156 insertions, 156 deletions
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index 5f8824c..d08e552 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs | |||
@@ -1,157 +1,157 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using libsecondlife; | 3 | using libsecondlife; |
4 | using OpenSim.Framework.Types; | 4 | using OpenSim.Framework.Types; |
5 | using OpenSim.Framework.Utilities; | 5 | using OpenSim.Framework.Utilities; |
6 | using OpenSim.Region.Environment.Interfaces; | 6 | using OpenSim.Region.Environment.Interfaces; |
7 | using OpenSim.Region.Environment.Scenes; | 7 | using OpenSim.Region.Environment.Scenes; |
8 | 8 | ||
9 | namespace OpenSim.Region.Environment.Modules | 9 | namespace OpenSim.Region.Environment.Modules |
10 | { | 10 | { |
11 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 11 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
12 | { | 12 | { |
13 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | 13 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); |
14 | 14 | ||
15 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 15 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
16 | new Dictionary<string, IDynamicTextureRender>(); | 16 | new Dictionary<string, IDynamicTextureRender>(); |
17 | 17 | ||
18 | private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); | 18 | private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); |
19 | 19 | ||
20 | public void Initialise(Scene scene) | 20 | public void Initialise(Scene scene) |
21 | { | 21 | { |
22 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) | 22 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) |
23 | { | 23 | { |
24 | RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); | 24 | RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); |
25 | scene.RegisterModuleInterface<IDynamicTextureManager>(this); | 25 | scene.RegisterModuleInterface<IDynamicTextureManager>(this); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | public void PostInitialise() | 29 | public void PostInitialise() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | public void CloseDown() | 33 | public void Close() |
34 | { | 34 | { |
35 | } | 35 | } |
36 | 36 | ||
37 | public string GetName() | 37 | public string Name |
38 | { | 38 | { |
39 | return "DynamicTextureModule"; | 39 | get { return "DynamicTextureModule"; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public bool IsSharedModule() | 42 | public bool IsSharedModule |
43 | { | 43 | { |
44 | return true; | 44 | get { return true; } |
45 | } | 45 | } |
46 | 46 | ||
47 | public void RegisterRender(string handleType, IDynamicTextureRender render) | 47 | public void RegisterRender(string handleType, IDynamicTextureRender render) |
48 | { | 48 | { |
49 | if (!RenderPlugins.ContainsKey(handleType)) | 49 | if (!RenderPlugins.ContainsKey(handleType)) |
50 | { | 50 | { |
51 | RenderPlugins.Add(handleType, render); | 51 | RenderPlugins.Add(handleType, render); |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | public void ReturnData(LLUUID id, byte[] data) | 55 | public void ReturnData(LLUUID id, byte[] data) |
56 | { | 56 | { |
57 | if (Updaters.ContainsKey(id)) | 57 | if (Updaters.ContainsKey(id)) |
58 | { | 58 | { |
59 | DynamicTextureUpdater updater = Updaters[id]; | 59 | DynamicTextureUpdater updater = Updaters[id]; |
60 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | 60 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) |
61 | { | 61 | { |
62 | Scene scene = RegisteredScenes[updater.SimUUID]; | 62 | Scene scene = RegisteredScenes[updater.SimUUID]; |
63 | updater.DataReceived(data, scene); | 63 | updater.DataReceived(data, scene); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, | 68 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, |
69 | string extraParams, int updateTimer) | 69 | string extraParams, int updateTimer) |
70 | { | 70 | { |
71 | Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); | 71 | Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); |
72 | if (RenderPlugins.ContainsKey(contentType)) | 72 | if (RenderPlugins.ContainsKey(contentType)) |
73 | { | 73 | { |
74 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 74 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); |
75 | updater.SimUUID = simID; | 75 | updater.SimUUID = simID; |
76 | updater.PrimID = primID; | 76 | updater.PrimID = primID; |
77 | updater.ContentType = contentType; | 77 | updater.ContentType = contentType; |
78 | updater.Url = url; | 78 | updater.Url = url; |
79 | updater.UpdateTimer = updateTimer; | 79 | updater.UpdateTimer = updateTimer; |
80 | updater.UpdaterID = LLUUID.Random(); | 80 | updater.UpdaterID = LLUUID.Random(); |
81 | updater.Params = extraParams; | 81 | updater.Params = extraParams; |
82 | 82 | ||
83 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 83 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
84 | { | 84 | { |
85 | Updaters.Add(updater.UpdaterID, updater); | 85 | Updaters.Add(updater.UpdaterID, updater); |
86 | } | 86 | } |
87 | 87 | ||
88 | RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); | 88 | RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); |
89 | return updater.UpdaterID; | 89 | return updater.UpdaterID; |
90 | } | 90 | } |
91 | return LLUUID.Zero; | 91 | return LLUUID.Zero; |
92 | } | 92 | } |
93 | 93 | ||
94 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, | 94 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, |
95 | string extraParams, int updateTimer) | 95 | string extraParams, int updateTimer) |
96 | { | 96 | { |
97 | if (RenderPlugins.ContainsKey(contentType)) | 97 | if (RenderPlugins.ContainsKey(contentType)) |
98 | { | 98 | { |
99 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 99 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); |
100 | updater.SimUUID = simID; | 100 | updater.SimUUID = simID; |
101 | updater.PrimID = primID; | 101 | updater.PrimID = primID; |
102 | updater.ContentType = contentType; | 102 | updater.ContentType = contentType; |
103 | updater.BodyData = data; | 103 | updater.BodyData = data; |
104 | updater.UpdateTimer = updateTimer; | 104 | updater.UpdateTimer = updateTimer; |
105 | updater.UpdaterID = LLUUID.Random(); | 105 | updater.UpdaterID = LLUUID.Random(); |
106 | updater.Params = extraParams; | 106 | updater.Params = extraParams; |
107 | 107 | ||
108 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 108 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
109 | { | 109 | { |
110 | Updaters.Add(updater.UpdaterID, updater); | 110 | Updaters.Add(updater.UpdaterID, updater); |
111 | } | 111 | } |
112 | 112 | ||
113 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); | 113 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); |
114 | return updater.UpdaterID; | 114 | return updater.UpdaterID; |
115 | } | 115 | } |
116 | return LLUUID.Zero; | 116 | return LLUUID.Zero; |
117 | } | 117 | } |
118 | 118 | ||
119 | public class DynamicTextureUpdater | 119 | public class DynamicTextureUpdater |
120 | { | 120 | { |
121 | public LLUUID SimUUID; | 121 | public LLUUID SimUUID; |
122 | public LLUUID UpdaterID; | 122 | public LLUUID UpdaterID; |
123 | public string ContentType; | 123 | public string ContentType; |
124 | public string Url; | 124 | public string Url; |
125 | public string BodyData; | 125 | public string BodyData; |
126 | public LLUUID PrimID; | 126 | public LLUUID PrimID; |
127 | public int UpdateTimer; | 127 | public int UpdateTimer; |
128 | public LLUUID LastAssetID; | 128 | public LLUUID LastAssetID; |
129 | public string Params; | 129 | public string Params; |
130 | 130 | ||
131 | public DynamicTextureUpdater() | 131 | public DynamicTextureUpdater() |
132 | { | 132 | { |
133 | LastAssetID = LLUUID.Zero; | 133 | LastAssetID = LLUUID.Zero; |
134 | UpdateTimer = 0; | 134 | UpdateTimer = 0; |
135 | BodyData = null; | 135 | BodyData = null; |
136 | } | 136 | } |
137 | 137 | ||
138 | public void DataReceived(byte[] data, Scene scene) | 138 | public void DataReceived(byte[] data, Scene scene) |
139 | { | 139 | { |
140 | //TODO delete the last asset(data), if it was a dynamic texture | 140 | //TODO delete the last asset(data), if it was a dynamic texture |
141 | 141 | ||
142 | AssetBase asset = new AssetBase(); | 142 | AssetBase asset = new AssetBase(); |
143 | asset.FullID = LLUUID.Random(); | 143 | asset.FullID = LLUUID.Random(); |
144 | asset.Data = data; | 144 | asset.Data = data; |
145 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); | 145 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); |
146 | asset.Type = 0; | 146 | asset.Type = 0; |
147 | scene.commsManager.AssetCache.AddAsset(asset); | 147 | scene.commsManager.AssetCache.AddAsset(asset); |
148 | 148 | ||
149 | LastAssetID = asset.FullID; | 149 | LastAssetID = asset.FullID; |
150 | 150 | ||
151 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); | 151 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); |
152 | part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); | 152 | part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); |
153 | part.ScheduleFullUpdate(); | 153 | part.ScheduleFullUpdate(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } \ No newline at end of file | 157 | } \ No newline at end of file |