aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
diff options
context:
space:
mode:
authorSean Dague2007-10-19 20:27:34 +0000
committerSean Dague2007-10-19 20:27:34 +0000
commit139994757c7dab04dd03801266525e8c53395a5e (patch)
tree003ec2557de6dd80dbe1e7bc78efe8958d02d5ae /OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
parent* Test thy commits! (oops, sorry!) (diff)
downloadopensim-SC_OLD-139994757c7dab04dd03801266525e8c53395a5e.zip
opensim-SC_OLD-139994757c7dab04dd03801266525e8c53395a5e.tar.gz
opensim-SC_OLD-139994757c7dab04dd03801266525e8c53395a5e.tar.bz2
opensim-SC_OLD-139994757c7dab04dd03801266525e8c53395a5e.tar.xz
changes to pass nini config object to the modules that get
loaded so that they may read out any bits they are interested in
Diffstat (limited to 'OpenSim/Region/Environment/Modules/DynamicTextureModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/DynamicTextureModule.cs381
1 files changed, 191 insertions, 190 deletions
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
index e776717..4e29977 100644
--- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
@@ -1,190 +1,191 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Framework.Types; 32using OpenSim.Framework.Types;
33using OpenSim.Framework.Utilities; 33using OpenSim.Framework.Utilities;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36using Nini.Config;
37namespace OpenSim.Region.Environment.Modules 37
38{ 38namespace OpenSim.Region.Environment.Modules
39 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager 39{
40 { 40 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
41 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 41 {
42 42 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
43 private Dictionary<string, IDynamicTextureRender> RenderPlugins = 43
44 new Dictionary<string, IDynamicTextureRender>(); 44 private Dictionary<string, IDynamicTextureRender> RenderPlugins =
45 45 new Dictionary<string, IDynamicTextureRender>();
46 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); 46
47 47 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
48 public void Initialise(Scene scene) 48
49 { 49 public void Initialise(Scene scene, IConfigSource config)
50 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 50 {
51 { 51 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
52 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 52 {
53 scene.RegisterModuleInterface<IDynamicTextureManager>(this); 53 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
54 } 54 scene.RegisterModuleInterface<IDynamicTextureManager>(this);
55 } 55 }
56 56 }
57 public void PostInitialise() 57
58 { 58 public void PostInitialise()
59 } 59 {
60 60 }
61 public void Close() 61
62 { 62 public void Close()
63 } 63 {
64 64 }
65 public string Name 65
66 { 66 public string Name
67 get { return "DynamicTextureModule"; } 67 {
68 } 68 get { return "DynamicTextureModule"; }
69 69 }
70 public bool IsSharedModule 70
71 { 71 public bool IsSharedModule
72 get { return true; } 72 {
73 } 73 get { return true; }
74 74 }
75 public void RegisterRender(string handleType, IDynamicTextureRender render) 75
76 { 76 public void RegisterRender(string handleType, IDynamicTextureRender render)
77 if (!RenderPlugins.ContainsKey(handleType)) 77 {
78 { 78 if (!RenderPlugins.ContainsKey(handleType))
79 RenderPlugins.Add(handleType, render); 79 {
80 } 80 RenderPlugins.Add(handleType, render);
81 } 81 }
82 82 }
83 public void ReturnData(LLUUID id, byte[] data) 83
84 { 84 public void ReturnData(LLUUID id, byte[] data)
85 if (Updaters.ContainsKey(id)) 85 {
86 { 86 if (Updaters.ContainsKey(id))
87 DynamicTextureUpdater updater = Updaters[id]; 87 {
88 if (RegisteredScenes.ContainsKey(updater.SimUUID)) 88 DynamicTextureUpdater updater = Updaters[id];
89 { 89 if (RegisteredScenes.ContainsKey(updater.SimUUID))
90 Scene scene = RegisteredScenes[updater.SimUUID]; 90 {
91 updater.DataReceived(data, scene); 91 Scene scene = RegisteredScenes[updater.SimUUID];
92 } 92 updater.DataReceived(data, scene);
93 } 93 }
94 } 94 }
95 95 }
96 public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, 96
97 string extraParams, int updateTimer) 97 public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url,
98 { 98 string extraParams, int updateTimer)
99 if (RenderPlugins.ContainsKey(contentType)) 99 {
100 { 100 if (RenderPlugins.ContainsKey(contentType))
101 //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); 101 {
102 102 //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
103 DynamicTextureUpdater updater = new DynamicTextureUpdater(); 103
104 updater.SimUUID = simID; 104 DynamicTextureUpdater updater = new DynamicTextureUpdater();
105 updater.PrimID = primID; 105 updater.SimUUID = simID;
106 updater.ContentType = contentType; 106 updater.PrimID = primID;
107 updater.Url = url; 107 updater.ContentType = contentType;
108 updater.UpdateTimer = updateTimer; 108 updater.Url = url;
109 updater.UpdaterID = LLUUID.Random(); 109 updater.UpdateTimer = updateTimer;
110 updater.Params = extraParams; 110 updater.UpdaterID = LLUUID.Random();
111 111 updater.Params = extraParams;
112 if (!Updaters.ContainsKey(updater.UpdaterID)) 112
113 { 113 if (!Updaters.ContainsKey(updater.UpdaterID))
114 Updaters.Add(updater.UpdaterID, updater); 114 {
115 } 115 Updaters.Add(updater.UpdaterID, updater);
116 116 }
117 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); 117
118 return updater.UpdaterID; 118 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
119 } 119 return updater.UpdaterID;
120 return LLUUID.Zero; 120 }
121 } 121 return LLUUID.Zero;
122 122 }
123 public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, 123
124 string extraParams, int updateTimer) 124 public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data,
125 { 125 string extraParams, int updateTimer)
126 if (RenderPlugins.ContainsKey(contentType)) 126 {
127 { 127 if (RenderPlugins.ContainsKey(contentType))
128 DynamicTextureUpdater updater = new DynamicTextureUpdater(); 128 {
129 updater.SimUUID = simID; 129 DynamicTextureUpdater updater = new DynamicTextureUpdater();
130 updater.PrimID = primID; 130 updater.SimUUID = simID;
131 updater.ContentType = contentType; 131 updater.PrimID = primID;
132 updater.BodyData = data; 132 updater.ContentType = contentType;
133 updater.UpdateTimer = updateTimer; 133 updater.BodyData = data;
134 updater.UpdaterID = LLUUID.Random(); 134 updater.UpdateTimer = updateTimer;
135 updater.Params = extraParams; 135 updater.UpdaterID = LLUUID.Random();
136 136 updater.Params = extraParams;
137 if (!Updaters.ContainsKey(updater.UpdaterID)) 137
138 { 138 if (!Updaters.ContainsKey(updater.UpdaterID))
139 Updaters.Add(updater.UpdaterID, updater); 139 {
140 } 140 Updaters.Add(updater.UpdaterID, updater);
141 141 }
142 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); 142
143 return updater.UpdaterID; 143 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
144 } 144 return updater.UpdaterID;
145 return LLUUID.Zero; 145 }
146 } 146 return LLUUID.Zero;
147 147 }
148 public class DynamicTextureUpdater 148
149 { 149 public class DynamicTextureUpdater
150 public LLUUID SimUUID; 150 {
151 public LLUUID UpdaterID; 151 public LLUUID SimUUID;
152 public string ContentType; 152 public LLUUID UpdaterID;
153 public string Url; 153 public string ContentType;
154 public string BodyData; 154 public string Url;
155 public LLUUID PrimID; 155 public string BodyData;
156 public int UpdateTimer; 156 public LLUUID PrimID;
157 public LLUUID LastAssetID; 157 public int UpdateTimer;
158 public string Params; 158 public LLUUID LastAssetID;
159 159 public string Params;
160 public DynamicTextureUpdater() 160
161 { 161 public DynamicTextureUpdater()
162 LastAssetID = LLUUID.Zero; 162 {
163 UpdateTimer = 0; 163 LastAssetID = LLUUID.Zero;
164 BodyData = null; 164 UpdateTimer = 0;
165 } 165 BodyData = null;
166 166 }
167 public void DataReceived(byte[] data, Scene scene) 167
168 { 168 public void DataReceived(byte[] data, Scene scene)
169 //TODO delete the last asset(data), if it was a dynamic texture 169 {
170 byte[] assetData = new byte[data.Length]; 170 //TODO delete the last asset(data), if it was a dynamic texture
171 Array.Copy(data, assetData, data.Length); 171 byte[] assetData = new byte[data.Length];
172 AssetBase asset = new AssetBase(); 172 Array.Copy(data, assetData, data.Length);
173 asset.FullID = LLUUID.Random(); 173 AssetBase asset = new AssetBase();
174 asset.Data = assetData; 174 asset.FullID = LLUUID.Random();
175 asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); 175 asset.Data = assetData;
176 asset.Type = 0; 176 asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
177 asset.Description = "dynamic image"; 177 asset.Type = 0;
178 asset.Local = false; 178 asset.Description = "dynamic image";
179 asset.Temporary = false; 179 asset.Local = false;
180 scene.commsManager.AssetCache.AddAsset(asset); 180 asset.Temporary = false;
181 181 scene.commsManager.AssetCache.AddAsset(asset);
182 LastAssetID = asset.FullID; 182
183 183 LastAssetID = asset.FullID;
184 SceneObjectPart part = scene.GetSceneObjectPart(PrimID); 184
185 part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); 185 SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
186 part.ScheduleFullUpdate(); 186 part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes();
187 } 187 part.ScheduleFullUpdate();
188 } 188 }
189 } 189 }
190} 190 }
191}