diff options
author | MW | 2008-03-08 20:54:34 +0000 |
---|---|---|
committer | MW | 2008-03-08 20:54:34 +0000 |
commit | d340820826635069813e088f6c17266fbeadd393 (patch) | |
tree | 7d1a3b53a267dbd2e4b1f95d79ba3639639c0558 /OpenSim | |
parent | * Implemented 'Revert' channel in Terrain Module. (diff) | |
download | opensim-SC-d340820826635069813e088f6c17266fbeadd393.zip opensim-SC-d340820826635069813e088f6c17266fbeadd393.tar.gz opensim-SC-d340820826635069813e088f6c17266fbeadd393.tar.bz2 opensim-SC-d340820826635069813e088f6c17266fbeadd393.tar.xz |
Added Frist basic version on the VectorRenderModule, that allows scripts to do some basic drawing onto textures. Currently the method the scripts have to use is most likely not the most user friendly, but this should improve soon. And hope to allow SVG files (either loaded from a web site, or even script created) to be used. I will add a page to the wiki tomorrow, until then http://www.pastebin.ca/934425 is a example c# script that can be used to get a bit of a idea.
Also added osSetDynamicTextureDataBlend and osSetDynamicTextureURLBlend that will allow the various textures to be blended together, but currently there are still a few bugs in them. So not ready for use yet.
Diffstat (limited to '')
7 files changed, 496 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs index d19e6b6..fab92e4 100644 --- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs | |||
@@ -38,9 +38,12 @@ namespace OpenSim.Region.Environment.Interfaces | |||
38 | 38 | ||
39 | LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, | 39 | LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, |
40 | int updateTimer); | 40 | int updateTimer); |
41 | 41 | LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, | |
42 | int updateTimer, bool SetBlending, byte AlphaValue); | ||
42 | LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, | 43 | LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, |
43 | int updateTimer); | 44 | int updateTimer); |
45 | LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, | ||
46 | int updateTimer, bool SetBlending, byte AlphaValue); | ||
44 | } | 47 | } |
45 | 48 | ||
46 | public interface IDynamicTextureRender | 49 | public interface IDynamicTextureRender |
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index fe7b763..2988feb 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs | |||
@@ -27,12 +27,14 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Drawing; | ||
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using libsecondlife; | 32 | using libsecondlife; |
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | using OpenJPEGNet; | ||
36 | 38 | ||
37 | namespace OpenSim.Region.Environment.Modules | 39 | namespace OpenSim.Region.Environment.Modules |
38 | { | 40 | { |
@@ -93,9 +95,16 @@ namespace OpenSim.Region.Environment.Modules | |||
93 | } | 95 | } |
94 | } | 96 | } |
95 | 97 | ||
98 | |||
96 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, | 99 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, |
97 | string extraParams, int updateTimer) | 100 | string extraParams, int updateTimer) |
98 | { | 101 | { |
102 | return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255); | ||
103 | } | ||
104 | |||
105 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, | ||
106 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) | ||
107 | { | ||
99 | if (RenderPlugins.ContainsKey(contentType)) | 108 | if (RenderPlugins.ContainsKey(contentType)) |
100 | { | 109 | { |
101 | //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); | 110 | //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); |
@@ -108,6 +117,8 @@ namespace OpenSim.Region.Environment.Modules | |||
108 | updater.UpdateTimer = updateTimer; | 117 | updater.UpdateTimer = updateTimer; |
109 | updater.UpdaterID = LLUUID.Random(); | 118 | updater.UpdaterID = LLUUID.Random(); |
110 | updater.Params = extraParams; | 119 | updater.Params = extraParams; |
120 | updater.BlendWithOldTexture = SetBlending; | ||
121 | updater.FrontAlpha = AlphaValue; | ||
111 | 122 | ||
112 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 123 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
113 | { | 124 | { |
@@ -121,7 +132,13 @@ namespace OpenSim.Region.Environment.Modules | |||
121 | } | 132 | } |
122 | 133 | ||
123 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, | 134 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, |
124 | string extraParams, int updateTimer) | 135 | string extraParams, int updateTimer) |
136 | { | ||
137 | return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255); | ||
138 | } | ||
139 | |||
140 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, | ||
141 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) | ||
125 | { | 142 | { |
126 | if (RenderPlugins.ContainsKey(contentType)) | 143 | if (RenderPlugins.ContainsKey(contentType)) |
127 | { | 144 | { |
@@ -133,6 +150,8 @@ namespace OpenSim.Region.Environment.Modules | |||
133 | updater.UpdateTimer = updateTimer; | 150 | updater.UpdateTimer = updateTimer; |
134 | updater.UpdaterID = LLUUID.Random(); | 151 | updater.UpdaterID = LLUUID.Random(); |
135 | updater.Params = extraParams; | 152 | updater.Params = extraParams; |
153 | updater.BlendWithOldTexture = SetBlending; | ||
154 | updater.FrontAlpha = AlphaValue; | ||
136 | 155 | ||
137 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 156 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
138 | { | 157 | { |
@@ -156,6 +175,9 @@ namespace OpenSim.Region.Environment.Modules | |||
156 | public int UpdateTimer; | 175 | public int UpdateTimer; |
157 | public LLUUID LastAssetID; | 176 | public LLUUID LastAssetID; |
158 | public string Params; | 177 | public string Params; |
178 | public bool BlendWithOldTexture = false; | ||
179 | public bool SetNewFrontAlpha = false; | ||
180 | public byte FrontAlpha = 255; | ||
159 | 181 | ||
160 | public DynamicTextureUpdater() | 182 | public DynamicTextureUpdater() |
161 | { | 183 | { |
@@ -166,9 +188,30 @@ namespace OpenSim.Region.Environment.Modules | |||
166 | 188 | ||
167 | public void DataReceived(byte[] data, Scene scene) | 189 | public void DataReceived(byte[] data, Scene scene) |
168 | { | 190 | { |
191 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); | ||
192 | byte[] assetData; | ||
193 | AssetBase oldAsset = null; | ||
194 | if (BlendWithOldTexture) | ||
195 | { | ||
196 | LLUUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; | ||
197 | oldAsset = scene.AssetCache.GetAsset(lastTextureID, true); | ||
198 | if (oldAsset != null) | ||
199 | { | ||
200 | assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | assetData = new byte[data.Length]; | ||
205 | Array.Copy(data, assetData, data.Length); | ||
206 | } | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | assetData = new byte[data.Length]; | ||
211 | Array.Copy(data, assetData, data.Length); | ||
212 | } | ||
213 | |||
169 | //TODO delete the last asset(data), if it was a dynamic texture | 214 | //TODO delete the last asset(data), if it was a dynamic texture |
170 | byte[] assetData = new byte[data.Length]; | ||
171 | Array.Copy(data, assetData, data.Length); | ||
172 | AssetBase asset = new AssetBase(); | 215 | AssetBase asset = new AssetBase(); |
173 | asset.FullID = LLUUID.Random(); | 216 | asset.FullID = LLUUID.Random(); |
174 | asset.Data = assetData; | 217 | asset.Data = assetData; |
@@ -181,10 +224,53 @@ namespace OpenSim.Region.Environment.Modules | |||
181 | 224 | ||
182 | LastAssetID = asset.FullID; | 225 | LastAssetID = asset.FullID; |
183 | 226 | ||
184 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); | 227 | |
185 | part.Shape.Textures = new LLObject.TextureEntry(asset.FullID); | 228 | part.Shape.Textures = new LLObject.TextureEntry(asset.FullID); |
186 | part.ScheduleFullUpdate(); | 229 | part.ScheduleFullUpdate(); |
187 | } | 230 | } |
231 | |||
232 | private byte[] BlendTextures(byte[] frontImage, byte[] backImage) | ||
233 | { | ||
234 | return BlendTextures(frontImage, backImage, false, 0); | ||
235 | } | ||
236 | |||
237 | private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) | ||
238 | { | ||
239 | Bitmap image1 = new Bitmap(OpenJPEG.DecodeToImage(frontImage)); | ||
240 | Bitmap image2 = new Bitmap(OpenJPEG.DecodeToImage(backImage)); | ||
241 | if (setNewAlpha) | ||
242 | { | ||
243 | SetAlpha(ref image1, newAlpha); | ||
244 | } | ||
245 | Bitmap joint = MergeBitMaps(image1, image2); | ||
246 | |||
247 | return OpenJPEG.EncodeFromImage(joint, true); | ||
248 | } | ||
249 | |||
250 | public Bitmap MergeBitMaps(Bitmap front, Bitmap back) | ||
251 | { | ||
252 | Bitmap joint; | ||
253 | Graphics jG; | ||
254 | |||
255 | joint = new Bitmap(back.Width, back.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); | ||
256 | jG = Graphics.FromImage(joint); | ||
257 | |||
258 | jG.DrawImage(back, 0, 0, back.Width, back.Height); | ||
259 | jG.DrawImage(front, 0, 0, back.Width, back.Height); | ||
260 | |||
261 | return joint; | ||
262 | } | ||
263 | |||
264 | private void SetAlpha(ref Bitmap b, byte alpha) | ||
265 | { | ||
266 | for (int w = 0; w < b.Width; w++) | ||
267 | { | ||
268 | for (int h = 0; h < b.Height; h++) | ||
269 | { | ||
270 | b.SetPixel(w, h, Color.FromArgb(alpha, b.GetPixel(w, h))); | ||
271 | } | ||
272 | } | ||
273 | } | ||
188 | } | 274 | } |
189 | } | 275 | } |
190 | } \ No newline at end of file | 276 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs index 0548b9d..1bfc647 100644 --- a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs | |||
@@ -38,6 +38,7 @@ using OpenSim.Region.Environment.Scenes; | |||
38 | 38 | ||
39 | namespace OpenSim.Region.Environment.Modules | 39 | namespace OpenSim.Region.Environment.Modules |
40 | { | 40 | { |
41 | |||
41 | public class LoadImageURLModule : IRegionModule, IDynamicTextureRender | 42 | public class LoadImageURLModule : IRegionModule, IDynamicTextureRender |
42 | { | 43 | { |
43 | private string m_name = "LoadImageURL"; | 44 | private string m_name = "LoadImageURL"; |
@@ -55,7 +56,10 @@ namespace OpenSim.Region.Environment.Modules | |||
55 | public void PostInitialise() | 56 | public void PostInitialise() |
56 | { | 57 | { |
57 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | 58 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); |
58 | m_textureManager.RegisterRender(GetContentType(), this); | 59 | if (m_textureManager != null) |
60 | { | ||
61 | m_textureManager.RegisterRender(GetContentType(), this); | ||
62 | } | ||
59 | } | 63 | } |
60 | 64 | ||
61 | public void Close() | 65 | public void Close() |
diff --git a/OpenSim/Region/Environment/Modules/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/VectorRenderModule.cs new file mode 100644 index 0000000..d033170 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/VectorRenderModule.cs | |||
@@ -0,0 +1,308 @@ | |||
1 |  | ||
2 | using System; | ||
3 | using System.Drawing; | ||
4 | using System.IO; | ||
5 | using System.Net; | ||
6 | using System.Globalization; | ||
7 | using libsecondlife; | ||
8 | using Nini.Config; | ||
9 | using OpenJPEGNet; | ||
10 | using OpenSim.Framework; | ||
11 | using OpenSim.Region.Environment.Interfaces; | ||
12 | using OpenSim.Region.Environment.Scenes; | ||
13 | //using Cairo; | ||
14 | |||
15 | namespace OpenSim.Region.Environment.Modules | ||
16 | { | ||
17 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender | ||
18 | { | ||
19 | private Scene m_scene; | ||
20 | private string m_name = "VectorRenderModule"; | ||
21 | private IDynamicTextureManager m_textureManager; | ||
22 | |||
23 | public VectorRenderModule() | ||
24 | { | ||
25 | } | ||
26 | |||
27 | public void Initialise(Scene scene, IConfigSource config) | ||
28 | { | ||
29 | if (m_scene == null) | ||
30 | { | ||
31 | m_scene = scene; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | public void PostInitialise() | ||
36 | { | ||
37 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | ||
38 | if (m_textureManager != null) | ||
39 | { | ||
40 | m_textureManager.RegisterRender(GetContentType(), this); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public void Close() | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public string Name | ||
49 | { | ||
50 | get { return m_name; } | ||
51 | } | ||
52 | |||
53 | public bool IsSharedModule | ||
54 | { | ||
55 | get { return true; } | ||
56 | } | ||
57 | |||
58 | private void Draw(string data, LLUUID id, string extraParams) | ||
59 | { | ||
60 | Bitmap bitmap = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb); | ||
61 | |||
62 | System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(bitmap); | ||
63 | |||
64 | extraParams = extraParams.ToLower(); | ||
65 | int alpha = 255; | ||
66 | if (extraParams == "setalpha") | ||
67 | { | ||
68 | alpha = 0; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | graph.FillRectangle(new SolidBrush(Color.White), 0, 0, 256, 256); | ||
73 | } | ||
74 | |||
75 | for (int w = 0; w < bitmap.Width; w++) | ||
76 | { | ||
77 | for (int h = 0; h < bitmap.Height; h++) | ||
78 | { | ||
79 | bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h))); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | GDIDraw(data, graph); | ||
86 | |||
87 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); | ||
88 | m_textureManager.ReturnData(id, imageJ2000); | ||
89 | |||
90 | } | ||
91 | |||
92 | /* private void CairoDraw(string data, System.Drawing.Graphics graph) | ||
93 | { | ||
94 | using (Win32Surface draw = new Win32Surface(graph.GetHdc())) | ||
95 | { | ||
96 | Context contex = new Context(draw); | ||
97 | |||
98 | contex.Antialias = Antialias.None; //fastest method but low quality | ||
99 | contex.LineWidth = 7; | ||
100 | char[] lineDelimiter = { ';' }; | ||
101 | char[] partsDelimiter = { ',' }; | ||
102 | string[] lines = data.Split(lineDelimiter); | ||
103 | |||
104 | foreach (string line in lines) | ||
105 | { | ||
106 | string nextLine = line.Trim(); | ||
107 | |||
108 | if (nextLine.StartsWith("MoveTO")) | ||
109 | { | ||
110 | float x = 0; | ||
111 | float y = 0; | ||
112 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); | ||
113 | contex.MoveTo(x, y); | ||
114 | } | ||
115 | else if (nextLine.StartsWith("LineTo")) | ||
116 | { | ||
117 | float x = 0; | ||
118 | float y = 0; | ||
119 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); | ||
120 | contex.LineTo(x, y); | ||
121 | contex.Stroke(); | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | graph.ReleaseHdc(); | ||
126 | }*/ | ||
127 | |||
128 | private void GDIDraw(string data, System.Drawing.Graphics graph) | ||
129 | { | ||
130 | System.Drawing.Point startPoint = new System.Drawing.Point(0, 0); | ||
131 | System.Drawing.Point endPoint = new System.Drawing.Point(0, 0); | ||
132 | System.Drawing.Pen drawPen = new Pen(System.Drawing.Color.Black, 7); | ||
133 | Font myFont = new Font("Times New Roman", 14); | ||
134 | SolidBrush myBrush = new SolidBrush(Color.Black); | ||
135 | char[] lineDelimiter = { ';' }; | ||
136 | char[] partsDelimiter = { ',' }; | ||
137 | string[] lines = data.Split(lineDelimiter); | ||
138 | |||
139 | |||
140 | foreach (string line in lines) | ||
141 | { | ||
142 | string nextLine = line.Trim(); | ||
143 | |||
144 | if (nextLine.StartsWith("MoveTo")) | ||
145 | { | ||
146 | float x = 0; | ||
147 | float y = 0; | ||
148 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); | ||
149 | startPoint.X = (int)x; | ||
150 | startPoint.Y = (int)y; | ||
151 | } | ||
152 | else if (nextLine.StartsWith("LineTo")) | ||
153 | { | ||
154 | float x = 0; | ||
155 | float y = 0; | ||
156 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); | ||
157 | endPoint.X = (int)x; | ||
158 | endPoint.Y = (int)y; | ||
159 | graph.DrawLine(drawPen, startPoint, endPoint); | ||
160 | startPoint.X = endPoint.X; | ||
161 | startPoint.Y = endPoint.Y; | ||
162 | } | ||
163 | else if (nextLine.StartsWith("Text")) | ||
164 | { | ||
165 | nextLine = nextLine.Remove(0, 4); | ||
166 | nextLine = nextLine.Trim(); | ||
167 | graph.DrawString(nextLine, myFont, myBrush, startPoint); | ||
168 | } | ||
169 | else if (nextLine.StartsWith("Image")) | ||
170 | { | ||
171 | float x = 0; | ||
172 | float y = 0; | ||
173 | GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); | ||
174 | endPoint.X = (int)x; | ||
175 | endPoint.Y = (int)y; | ||
176 | System.Drawing.Image image = ImageHttpRequest(nextLine); | ||
177 | graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y); | ||
178 | startPoint.X += endPoint.X; | ||
179 | startPoint.Y += endPoint.Y; | ||
180 | } | ||
181 | else if (nextLine.StartsWith("Rectangle")) | ||
182 | { | ||
183 | float x = 0; | ||
184 | float y = 0; | ||
185 | GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y); | ||
186 | endPoint.X = (int)x; | ||
187 | endPoint.Y = (int)y; | ||
188 | graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | ||
189 | startPoint.X += endPoint.X; | ||
190 | startPoint.Y += endPoint.Y; | ||
191 | } | ||
192 | else if (nextLine.StartsWith("FillRectangle")) | ||
193 | { | ||
194 | float x = 0; | ||
195 | float y = 0; | ||
196 | GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y); | ||
197 | endPoint.X = (int)x; | ||
198 | endPoint.Y = (int)y; | ||
199 | graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | ||
200 | startPoint.X += endPoint.X; | ||
201 | startPoint.Y += endPoint.Y; | ||
202 | } | ||
203 | else if (nextLine.StartsWith("Ellipse")) | ||
204 | { | ||
205 | float x = 0; | ||
206 | float y = 0; | ||
207 | GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); | ||
208 | endPoint.X = (int)x; | ||
209 | endPoint.Y = (int)y; | ||
210 | graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | ||
211 | startPoint.X += endPoint.X; | ||
212 | startPoint.Y += endPoint.Y; | ||
213 | } | ||
214 | else if (nextLine.StartsWith("FontSize")) | ||
215 | { | ||
216 | nextLine = nextLine.Remove(0, 8); | ||
217 | nextLine = nextLine.Trim(); | ||
218 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); | ||
219 | myFont = new Font("Times New Roman", size); | ||
220 | } | ||
221 | else if (nextLine.StartsWith("PenSize")) | ||
222 | { | ||
223 | nextLine = nextLine.Remove(0, 8); | ||
224 | nextLine = nextLine.Trim(); | ||
225 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); | ||
226 | drawPen.Width = size; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref float x, ref float y) | ||
232 | { | ||
233 | line = line.Remove(0, startLength); | ||
234 | string[] parts = line.Split(partsDelimiter); | ||
235 | if (parts.Length == 2) | ||
236 | { | ||
237 | string xVal = parts[0].Trim(); | ||
238 | string yVal = parts[1].Trim(); | ||
239 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); | ||
240 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); | ||
241 | } | ||
242 | else if (parts.Length > 2) | ||
243 | { | ||
244 | string xVal = parts[0].Trim(); | ||
245 | string yVal = parts[1].Trim(); | ||
246 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); | ||
247 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); | ||
248 | |||
249 | line = ""; | ||
250 | for (int i = 2; i < parts.Length; i++) | ||
251 | { | ||
252 | line = line + parts[i].Trim(); | ||
253 | line = line + " "; | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | |||
258 | private Bitmap ImageHttpRequest(string url) | ||
259 | { | ||
260 | WebRequest request = HttpWebRequest.Create(url); | ||
261 | Stream str = null; | ||
262 | HttpWebResponse response = (HttpWebResponse)(request).GetResponse(); | ||
263 | if (response.StatusCode == HttpStatusCode.OK) | ||
264 | { | ||
265 | Bitmap image = new Bitmap(response.GetResponseStream()); | ||
266 | return image; | ||
267 | } | ||
268 | |||
269 | return null; | ||
270 | } | ||
271 | |||
272 | public string GetContentType() | ||
273 | { | ||
274 | return ("vector"); | ||
275 | } | ||
276 | |||
277 | public string GetName() | ||
278 | { | ||
279 | return m_name; | ||
280 | } | ||
281 | |||
282 | public bool SupportsAsynchronous() | ||
283 | { | ||
284 | return true; | ||
285 | } | ||
286 | |||
287 | public byte[] ConvertUrl(string url, string extraParams) | ||
288 | { | ||
289 | return null; | ||
290 | } | ||
291 | |||
292 | public byte[] ConvertStream(Stream data, string extraParams) | ||
293 | { | ||
294 | return null; | ||
295 | } | ||
296 | |||
297 | public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) | ||
298 | { | ||
299 | return false; | ||
300 | } | ||
301 | |||
302 | public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) | ||
303 | { | ||
304 | Draw(bodyData, id, extraParams); | ||
305 | return true; | ||
306 | } | ||
307 | } | ||
308 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 922b301..79a106b 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs | |||
@@ -1849,6 +1849,24 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1849 | return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); | 1849 | return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); |
1850 | } | 1850 | } |
1851 | 1851 | ||
1852 | public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, | ||
1853 | int timer) | ||
1854 | { | ||
1855 | return m_LSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer); | ||
1856 | } | ||
1857 | |||
1858 | public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | ||
1859 | int timer, int alpha) | ||
1860 | { | ||
1861 | return m_LSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha); | ||
1862 | } | ||
1863 | |||
1864 | public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, | ||
1865 | int timer, int alpha) | ||
1866 | { | ||
1867 | return m_LSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha); | ||
1868 | } | ||
1869 | |||
1852 | public double osTerrainGetHeight(int x, int y) | 1870 | public double osTerrainGetHeight(int x, int y) |
1853 | { | 1871 | { |
1854 | return m_LSL_Functions.osTerrainGetHeight(x, y); | 1872 | return m_LSL_Functions.osTerrainGetHeight(x, y); |
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 7da47d4..93de3b4 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -4265,6 +4265,72 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
4265 | return LLUUID.Zero.ToString(); | 4265 | return LLUUID.Zero.ToString(); |
4266 | } | 4266 | } |
4267 | 4267 | ||
4268 | public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | ||
4269 | int timer, int alpha) | ||
4270 | { | ||
4271 | m_host.AddScriptLPS(1); | ||
4272 | if (dynamicID == String.Empty) | ||
4273 | { | ||
4274 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
4275 | LLUUID createdTexture = | ||
4276 | textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, | ||
4277 | extraParams, timer, true, (byte) alpha ); | ||
4278 | return createdTexture.ToString(); | ||
4279 | } | ||
4280 | else | ||
4281 | { | ||
4282 | //TODO update existing dynamic textures | ||
4283 | } | ||
4284 | |||
4285 | return LLUUID.Zero.ToString(); | ||
4286 | } | ||
4287 | |||
4288 | public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, | ||
4289 | int timer) | ||
4290 | { | ||
4291 | m_host.AddScriptLPS(1); | ||
4292 | if (dynamicID == String.Empty) | ||
4293 | { | ||
4294 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
4295 | if (textureManager != null) | ||
4296 | { | ||
4297 | LLUUID createdTexture = | ||
4298 | textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, | ||
4299 | extraParams, timer); | ||
4300 | return createdTexture.ToString(); | ||
4301 | } | ||
4302 | } | ||
4303 | else | ||
4304 | { | ||
4305 | //TODO update existing dynamic textures | ||
4306 | } | ||
4307 | |||
4308 | return LLUUID.Zero.ToString(); | ||
4309 | } | ||
4310 | |||
4311 | public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, | ||
4312 | int timer, int alpha) | ||
4313 | { | ||
4314 | m_host.AddScriptLPS(1); | ||
4315 | if (dynamicID == String.Empty) | ||
4316 | { | ||
4317 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
4318 | if (textureManager != null) | ||
4319 | { | ||
4320 | LLUUID createdTexture = | ||
4321 | textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, | ||
4322 | extraParams, timer, true, (byte) alpha); | ||
4323 | return createdTexture.ToString(); | ||
4324 | } | ||
4325 | } | ||
4326 | else | ||
4327 | { | ||
4328 | //TODO update existing dynamic textures | ||
4329 | } | ||
4330 | |||
4331 | return LLUUID.Zero.ToString(); | ||
4332 | } | ||
4333 | |||
4268 | public bool osConsoleCommand(string command) | 4334 | public bool osConsoleCommand(string command) |
4269 | { | 4335 | { |
4270 | m_host.AddScriptLPS(1); | 4336 | m_host.AddScriptLPS(1); |
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index c1e178b..c6d683c 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs | |||
@@ -637,6 +637,11 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
637 | string llStringTrim(string src, int type); | 637 | string llStringTrim(string src, int type); |
638 | //OpenSim functions | 638 | //OpenSim functions |
639 | string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); | 639 | string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); |
640 | string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | ||
641 | int timer, int alpha); | ||
642 | string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); | ||
643 | string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, | ||
644 | int timer, int alpha); | ||
640 | double osTerrainGetHeight(int x, int y); | 645 | double osTerrainGetHeight(int x, int y); |
641 | int osTerrainSetHeight(int x, int y, double val); | 646 | int osTerrainSetHeight(int x, int y, double val); |
642 | int osRegionRestart(double seconds); | 647 | int osRegionRestart(double seconds); |