aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule
diff options
context:
space:
mode:
authorAdam Frisby2009-04-09 14:19:49 +0000
committerAdam Frisby2009-04-09 14:19:49 +0000
commitc77e7fce9ebbdb0a7a5baee316fcf940bf641416 (patch)
tree5930b5f6c76983c1fe4ea44285ad6f163570b953 /OpenSim/Region/OptionalModules/Scripting/Minimodule
parent* Adds World.OnNewUser += delegate(IWorld sender, NewUserEventArgs e); (diff)
downloadopensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.zip
opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.gz
opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.bz2
opensim-SC-c77e7fce9ebbdb0a7a5baee316fcf940bf641416.tar.xz
* Implements IGraphics interface for MRM Scripting.
* This allows you to utilize System.Drawing tools on textures within the region. * Example: use System.Drawing.Bitmap to make your texture, then use Host.Graphics.SaveBitmap to make an asset from it in JPEG2K. You can edit (but not overwrite) existing textures using Host.Graphics.LoadBitmap.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs48
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs13
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs12
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs5
6 files changed, 75 insertions, 6 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
new file mode 100644
index 0000000..4de249f
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
@@ -0,0 +1,48 @@
1using System.Drawing;
2using OpenMetaverse;
3using OpenMetaverse.Imaging;
4using OpenSim.Framework;
5using OpenSim.Region.Framework.Scenes;
6
7namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
8{
9 class Graphics : IGraphics
10 {
11 private readonly Scene m_scene;
12
13 public Graphics(Scene m_scene)
14 {
15 this.m_scene = m_scene;
16 }
17
18 public UUID SaveBitmap(Bitmap data)
19 {
20 return SaveBitmap(data, false, true);
21 }
22
23 public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
24 {
25 AssetBase asset = new AssetBase();
26 asset.FullID = UUID.Random();
27 asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
28 asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000);
29 asset.Type = 0;
30 asset.Description = "MRM Image";
31 asset.Local = false;
32 asset.Temporary = temporary;
33 m_scene.CommsManager.AssetCache.AddAsset(asset);
34
35 return asset.FullID;
36 }
37
38 public Bitmap LoadBitmap(UUID assetID)
39 {
40 AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true);
41 ManagedImage outimg;
42 Image img;
43 OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img);
44
45 return new Bitmap(img);
46 }
47 }
48}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs
index 394e024..f5953d0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs
@@ -27,6 +27,7 @@
27 27
28using System.Reflection; 28using System.Reflection;
29using log4net; 29using log4net;
30using OpenSim.Region.Framework.Scenes;
30 31
31namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
32{ 33{
@@ -34,10 +35,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
34 { 35 {
35 private readonly IObject m_obj; 36 private readonly IObject m_obj;
36 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 private readonly IGraphics m_graphics;
39 private Scene m_scene;
37 40
38 public Host(IObject m_obj) 41 public Host(IObject m_obj, Scene m_scene)
39 { 42 {
40 this.m_obj = m_obj; 43 this.m_obj = m_obj;
44 this.m_scene = m_scene;
45
46 m_graphics = new Graphics(m_scene);
41 } 47 }
42 48
43 public IObject Object 49 public IObject Object
@@ -49,5 +55,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
49 { 55 {
50 get { return m_log; } 56 get { return m_log; }
51 } 57 }
58
59 public IGraphics Graphics
60 {
61 get { return m_graphics; }
62 }
52 } 63 }
53} 64}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs
new file mode 100644
index 0000000..f4bc12e
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs
@@ -0,0 +1,12 @@
1using System.Drawing;
2using OpenMetaverse;
3
4namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
5{
6 public interface IGraphics
7 {
8 UUID SaveBitmap(Bitmap data);
9 UUID SaveBitmap(Bitmap data, bool lossless, bool temporary);
10 Bitmap LoadBitmap(UUID assetID);
11 }
12}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs
index deb7c57..6c76919 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs
@@ -36,5 +36,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
36 { 36 {
37 IObject Object { get; } 37 IObject Object { get; }
38 ILog Console { get; } 38 ILog Console { get; }
39 IGraphics Graphics { get; }
39 } 40 }
40} 41}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 910ddea..b978d7c 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
82 { 82 {
83 m_log.Info("[MRM] Found C# MRM"); 83 m_log.Info("[MRM] Found C# MRM");
84 IWorld m_world = new World(m_scene); 84 IWorld m_world = new World(m_scene);
85 IHost m_host = new Host(new SOPObject(m_scene, localID)); 85 IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene);
86 86
87 MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( 87 MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
88 CompileFromDotNetText(script, itemID.ToString()), 88 CompileFromDotNetText(script, itemID.ToString()),
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
index 2280022..f2b3e81 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
@@ -26,10 +26,7 @@
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection;
30using log4net;
31using OpenSim.Framework; 29using OpenSim.Framework;
32using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 30using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
35 32
@@ -159,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
159 // Skip if other 156 // Skip if other
160 } 157 }
161 158
162 void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat) 159 void EventManager_OnChatFromClient(object sender, OSChatMessage chat)
163 { 160 {
164 if (_OnChat != null) 161 if (_OnChat != null)
165 { 162 {