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