* 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.0.6.5-rc1
parent
98eda9ebdb
commit
c77e7fce9e
|
@ -0,0 +1,48 @@
|
|||
using System.Drawing;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Imaging;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
class Graphics : IGraphics
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public Graphics(Scene m_scene)
|
||||
{
|
||||
this.m_scene = m_scene;
|
||||
}
|
||||
|
||||
public UUID SaveBitmap(Bitmap data)
|
||||
{
|
||||
return SaveBitmap(data, false, true);
|
||||
}
|
||||
|
||||
public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
|
||||
{
|
||||
AssetBase asset = new AssetBase();
|
||||
asset.FullID = UUID.Random();
|
||||
asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
|
||||
asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000);
|
||||
asset.Type = 0;
|
||||
asset.Description = "MRM Image";
|
||||
asset.Local = false;
|
||||
asset.Temporary = temporary;
|
||||
m_scene.CommsManager.AssetCache.AddAsset(asset);
|
||||
|
||||
return asset.FullID;
|
||||
}
|
||||
|
||||
public Bitmap LoadBitmap(UUID assetID)
|
||||
{
|
||||
AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true);
|
||||
ManagedImage outimg;
|
||||
Image img;
|
||||
OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img);
|
||||
|
||||
return new Bitmap(img);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
|
@ -34,10 +35,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
private readonly IObject m_obj;
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private readonly IGraphics m_graphics;
|
||||
private Scene m_scene;
|
||||
|
||||
public Host(IObject m_obj)
|
||||
public Host(IObject m_obj, Scene m_scene)
|
||||
{
|
||||
this.m_obj = m_obj;
|
||||
this.m_scene = m_scene;
|
||||
|
||||
m_graphics = new Graphics(m_scene);
|
||||
}
|
||||
|
||||
public IObject Object
|
||||
|
@ -49,5 +55,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
get { return m_log; }
|
||||
}
|
||||
|
||||
public IGraphics Graphics
|
||||
{
|
||||
get { return m_graphics; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using System.Drawing;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
public interface IGraphics
|
||||
{
|
||||
UUID SaveBitmap(Bitmap data);
|
||||
UUID SaveBitmap(Bitmap data, bool lossless, bool temporary);
|
||||
Bitmap LoadBitmap(UUID assetID);
|
||||
}
|
||||
}
|
|
@ -36,5 +36,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
IObject Object { get; }
|
||||
ILog Console { get; }
|
||||
IGraphics Graphics { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
m_log.Info("[MRM] Found C# MRM");
|
||||
IWorld m_world = new World(m_scene);
|
||||
IHost m_host = new Host(new SOPObject(m_scene, localID));
|
||||
IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene);
|
||||
|
||||
MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
|
||||
CompileFromDotNetText(script, itemID.ToString()),
|
||||
|
|
|
@ -26,10 +26,7 @@
|
|||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
@ -159,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
// Skip if other
|
||||
}
|
||||
|
||||
void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat)
|
||||
void EventManager_OnChatFromClient(object sender, OSChatMessage chat)
|
||||
{
|
||||
if (_OnChat != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue