Update svn properties.

0.6.4-rc1
Jeff Ames 2009-03-07 02:00:18 +00:00
parent ebe84907ae
commit e1f68145be
13 changed files with 855 additions and 855 deletions

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenSim.Region.CoreModules.World.Tests namespace OpenSim.Region.CoreModules.World.Tests
{ {
class SOGSpamTest class SOGSpamTest
{ {
} }
} }

View File

@ -1,34 +1,34 @@
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public class Heightmap : IHeightmap public class Heightmap : IHeightmap
{ {
private Scene m_scene; private Scene m_scene;
public Heightmap(Scene scene) public Heightmap(Scene scene)
{ {
m_scene = scene; m_scene = scene;
} }
public int Height public int Height
{ {
get { return m_scene.Heightmap.Height; } get { return m_scene.Heightmap.Height; }
} }
public int Width public int Width
{ {
get { return m_scene.Heightmap.Width; } get { return m_scene.Heightmap.Width; }
} }
public double Get(int x, int y) public double Get(int x, int y)
{ {
return m_scene.Heightmap[x, y]; return m_scene.Heightmap[x, y];
} }
public void Set(int x, int y, double val) public void Set(int x, int y, double val)
{ {
m_scene.Heightmap[x, y] = val; m_scene.Heightmap[x, y] = val;
} }
} }
} }

View File

@ -1,29 +1,29 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
class Host : IHost class Host : IHost
{ {
private readonly IObject m_obj; private readonly IObject m_obj;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Host(IObject m_obj) public Host(IObject m_obj)
{ {
this.m_obj = m_obj; this.m_obj = m_obj;
} }
public IObject Object public IObject Object
{ {
get { return m_obj; } get { return m_obj; }
} }
public ILog Console public ILog Console
{ {
get { return m_log; } get { return m_log; }
} }
} }
} }

View File

@ -1,14 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
interface IAvatar interface IAvatar
{ {
string Name { get; } string Name { get; }
UUID GlobalID { get; } UUID GlobalID { get; }
Vector3 Position { get; } Vector3 Position { get; }
} }
} }

View File

@ -1,14 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IHeightmap public interface IHeightmap
{ {
int Height { get; } int Height { get; }
int Width { get; } int Width { get; }
double Get(int x, int y); double Get(int x, int y);
void Set(int x, int y, double val); void Set(int x, int y, double val);
} }
} }

View File

@ -1,13 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using log4net; using log4net;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IHost public interface IHost
{ {
IObject Object { get; } IObject Object { get; }
ILog Console { get; } ILog Console { get; }
} }
} }

View File

@ -1,96 +1,96 @@
using System; using System;
using System.Drawing; using System.Drawing;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IObject public interface IObject
{ {
bool Exists { get; } bool Exists { get; }
uint LocalID { get; } uint LocalID { get; }
UUID GlobalID { get; } UUID GlobalID { get; }
IObject[] Children { get; } IObject[] Children { get; }
/// <summary> /// <summary>
/// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset. /// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset.
/// </summary> /// </summary>
IObject Root { get; } IObject Root { get; }
IObjectFace[] Faces { get; } IObjectFace[] Faces { get; }
Vector3 Scale { get; set; } Vector3 Scale { get; set; }
Quaternion Rotation { get; set; } Quaternion Rotation { get; set; }
Vector3 SitTarget { get; set; } Vector3 SitTarget { get; set; }
String SitTargetText { get; set; } String SitTargetText { get; set; }
String TouchText { get; set; } String TouchText { get; set; }
String Text { get; set; } String Text { get; set; }
bool IsPhysical { get; set; } // SetStatus(PHYSICS) bool IsPhysical { get; set; } // SetStatus(PHYSICS)
bool IsPhantom { get; set; } // SetStatus(PHANTOM) bool IsPhantom { get; set; } // SetStatus(PHANTOM)
bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X)
bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y)
bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z)
bool IsSandboxed { get; set; } // SetStatus(SANDBOX) bool IsSandboxed { get; set; } // SetStatus(SANDBOX)
bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB)
bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE)
bool IsTemporary { get; set; } // TEMP_ON_REZ bool IsTemporary { get; set; } // TEMP_ON_REZ
bool IsFlexible { get; set; } bool IsFlexible { get; set; }
PrimType PrimShape { get; set; } PrimType PrimShape { get; set; }
// TODO: // TODO:
// PrimHole // PrimHole
// Repeats, Offsets, Cut/Dimple/ProfileCut // Repeats, Offsets, Cut/Dimple/ProfileCut
// Hollow, Twist, HoleSize, // Hollow, Twist, HoleSize,
// Taper[A+B], Shear[A+B], Revolutions, // Taper[A+B], Shear[A+B], Revolutions,
// RadiusOffset, Skew // RadiusOffset, Skew
Material Material { get; set; } Material Material { get; set; }
} }
public enum Material public enum Material
{ {
Default, Default,
Glass, Glass,
Metal, Metal,
Plastic, Plastic,
Wood, Wood,
Rubber, Rubber,
Stone, Stone,
Flesh Flesh
} }
public enum PrimType public enum PrimType
{ {
NotPrimitive = 255, NotPrimitive = 255,
Box = 0, Box = 0,
Cylinder = 1, Cylinder = 1,
Prism = 2, Prism = 2,
Sphere = 3, Sphere = 3,
Torus = 4, Torus = 4,
Tube = 5, Tube = 5,
Ring = 6, Ring = 6,
Sculpt = 7 Sculpt = 7
} }
public enum TextureMapping public enum TextureMapping
{ {
Default, Default,
Planar Planar
} }
public interface IObjectFace public interface IObjectFace
{ {
Color Color { get; set; } Color Color { get; set; }
UUID Texture { get; set; } UUID Texture { get; set; }
TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN)
bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) bool Bright { get; set; } // SetPrimParms(FULLBRIGHT)
double Bloom { get; set; } // SetPrimParms(GLOW) double Bloom { get; set; } // SetPrimParms(GLOW)
bool Shiny { get; set; } // SetPrimParms(SHINY) bool Shiny { get; set; } // SetPrimParms(SHINY)
bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?]
} }
} }

View File

@ -1,12 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IWorld public interface IWorld
{ {
IObject[] Objects { get; } IObject[] Objects { get; }
IHeightmap Terrain { get; } IHeightmap Terrain { get; }
} }
} }

View File

@ -1,27 +1,27 @@
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public abstract class MRMBase public abstract class MRMBase
{ {
private IWorld m_world; private IWorld m_world;
private IHost m_host; private IHost m_host;
public void InitMiniModule(IWorld world, IHost host) public void InitMiniModule(IWorld world, IHost host)
{ {
m_world = world; m_world = world;
m_host = host; m_host = host;
} }
protected IWorld World protected IWorld World
{ {
get { return m_world; } get { return m_world; }
} }
protected IHost Host protected IHost Host
{ {
get { return m_host; } get { return m_host; }
} }
public abstract void Start(); public abstract void Start();
public abstract void Stop(); public abstract void Stop();
} }
} }

View File

@ -1,235 +1,235 @@
using System; using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
using Microsoft.CSharp; using Microsoft.CSharp;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public class MRMModule : IRegionModule public class MRMModule : IRegionModule
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene; private Scene m_scene;
private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>();
private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
public void Initialise(Scene scene, IConfigSource source) public void Initialise(Scene scene, IConfigSource source)
{ {
if (source.Configs["MRM"] != null) if (source.Configs["MRM"] != null)
{ {
if (source.Configs["MRM"].GetBoolean("Enabled", false)) if (source.Configs["MRM"].GetBoolean("Enabled", false))
{ {
m_log.Info("[MRM] Enabling MRM Module"); m_log.Info("[MRM] Enabling MRM Module");
m_scene = scene; m_scene = scene;
scene.EventManager.OnRezScript += EventManager_OnRezScript; scene.EventManager.OnRezScript += EventManager_OnRezScript;
} }
else else
{ {
m_log.Info("[MRM] Disabled MRM Module (Express)"); m_log.Info("[MRM] Disabled MRM Module (Express)");
} }
} }
else else
{ {
m_log.Info("[MRM] Disabled MRM Module (Omission)"); m_log.Info("[MRM] Disabled MRM Module (Omission)");
} }
} }
void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{ {
if (script.StartsWith("//MiniMod:C#")) if (script.StartsWith("//MiniMod:C#"))
{ {
m_log.Info("[MRM] Found C# MRM"); m_log.Info("[MRM] Found C# MRM");
IWorld m_world = new World(m_scene); 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));
MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
CompileFromDotNetText(script, itemID.ToString()), CompileFromDotNetText(script, itemID.ToString()),
"OpenSim.MiniModule"); "OpenSim.MiniModule");
m_log.Info("[MRM] Created MRM Instance"); m_log.Info("[MRM] Created MRM Instance");
mmb.InitMiniModule(m_world, m_host); mmb.InitMiniModule(m_world, m_host);
m_scripts[itemID] = mmb; m_scripts[itemID] = mmb;
m_log.Info("[MRM] Starting MRM"); m_log.Info("[MRM] Starting MRM");
mmb.Start(); mmb.Start();
} }
} }
public void PostInitialise() public void PostInitialise()
{ {
} }
public void Close() public void Close()
{ {
foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
{ {
pair.Value.Stop(); pair.Value.Stop();
} }
} }
public string Name public string Name
{ {
get { return "MiniRegionModule"; } get { return "MiniRegionModule"; }
} }
public bool IsSharedModule public bool IsSharedModule
{ {
get { return false; } get { return false; }
} }
/// <summary> /// <summary>
/// Stolen from ScriptEngine Common /// Stolen from ScriptEngine Common
/// </summary> /// </summary>
/// <param name="Script"></param> /// <param name="Script"></param>
/// <param name="uuid">Unique ID for this module</param> /// <param name="uuid">Unique ID for this module</param>
/// <returns></returns> /// <returns></returns>
internal string CompileFromDotNetText(string Script, string uuid) internal string CompileFromDotNetText(string Script, string uuid)
{ {
const string ext = ".cs"; const string ext = ".cs";
const string FilePrefix = "MiniModule"; const string FilePrefix = "MiniModule";
// Output assembly name // Output assembly name
string OutFile = Path.Combine("MiniModules", Path.Combine( string OutFile = Path.Combine("MiniModules", Path.Combine(
m_scene.RegionInfo.RegionID.ToString(), m_scene.RegionInfo.RegionID.ToString(),
FilePrefix + "_compiled_" + uuid + ".dll")); FilePrefix + "_compiled_" + uuid + ".dll"));
// Create Directories for Assemblies // Create Directories for Assemblies
if (!Directory.Exists("MiniModules")) if (!Directory.Exists("MiniModules"))
Directory.CreateDirectory("MiniModules"); Directory.CreateDirectory("MiniModules");
string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString());
if (!Directory.Exists(tmp)) if (!Directory.Exists(tmp))
Directory.CreateDirectory(tmp); Directory.CreateDirectory(tmp);
try try
{ {
File.Delete(OutFile); File.Delete(OutFile);
} }
catch (IOException e) catch (IOException e)
{ {
throw new Exception("Unable to delete old existing " + throw new Exception("Unable to delete old existing " +
"script-file before writing new. Compile aborted: " + "script-file before writing new. Compile aborted: " +
e); e);
} }
// DEBUG - write source to disk // DEBUG - write source to disk
string srcFileName = FilePrefix + "_source_" + string srcFileName = FilePrefix + "_source_" +
Path.GetFileNameWithoutExtension(OutFile) + ext; Path.GetFileNameWithoutExtension(OutFile) + ext;
try try
{ {
File.WriteAllText(Path.Combine(Path.Combine( File.WriteAllText(Path.Combine(Path.Combine(
"MiniModules", "MiniModules",
m_scene.RegionInfo.RegionID.ToString()), m_scene.RegionInfo.RegionID.ToString()),
srcFileName), Script); srcFileName), Script);
} }
catch (Exception ex) //NOTLEGIT - Should be just FileIOException catch (Exception ex) //NOTLEGIT - Should be just FileIOException
{ {
m_log.Error("[Compiler]: Exception while " + m_log.Error("[Compiler]: Exception while " +
"trying to write script source to file \"" + "trying to write script source to file \"" +
srcFileName + "\": " + ex.ToString()); srcFileName + "\": " + ex.ToString());
} }
// Do actual compile // Do actual compile
CompilerParameters parameters = new CompilerParameters(); CompilerParameters parameters = new CompilerParameters();
parameters.IncludeDebugInformation = true; parameters.IncludeDebugInformation = true;
string rootPath = string rootPath =
Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
// TODO: Add Libraries // TODO: Add Libraries
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
"OpenSim.Region.OptionalModules.dll")); "OpenSim.Region.OptionalModules.dll"));
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
"log4net.dll")); "log4net.dll"));
parameters.GenerateExecutable = false; parameters.GenerateExecutable = false;
parameters.OutputAssembly = OutFile; parameters.OutputAssembly = OutFile;
parameters.IncludeDebugInformation = true; parameters.IncludeDebugInformation = true;
parameters.TreatWarningsAsErrors = false; parameters.TreatWarningsAsErrors = false;
CompilerResults results = CScodeProvider.CompileAssemblyFromSource( CompilerResults results = CScodeProvider.CompileAssemblyFromSource(
parameters, Script); parameters, Script);
int display = 5; int display = 5;
if (results.Errors.Count > 0) if (results.Errors.Count > 0)
{ {
string errtext = String.Empty; string errtext = String.Empty;
foreach (CompilerError CompErr in results.Errors) foreach (CompilerError CompErr in results.Errors)
{ {
// Show 5 errors max // Show 5 errors max
// //
if (display <= 0) if (display <= 0)
break; break;
display--; display--;
string severity = "Error"; string severity = "Error";
if (CompErr.IsWarning) if (CompErr.IsWarning)
{ {
severity = "Warning"; severity = "Warning";
} }
string text = CompErr.ErrorText; string text = CompErr.ErrorText;
// The Second Life viewer's script editor begins // The Second Life viewer's script editor begins
// countingn lines and columns at 0, so we subtract 1. // countingn lines and columns at 0, so we subtract 1.
errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n",
CompErr.Line - 1, CompErr.Column - 1, CompErr.Line - 1, CompErr.Column - 1,
CompErr.ErrorNumber, text, severity); CompErr.ErrorNumber, text, severity);
} }
if (!File.Exists(OutFile)) if (!File.Exists(OutFile))
{ {
throw new Exception(errtext); throw new Exception(errtext);
} }
} }
if (!File.Exists(OutFile)) if (!File.Exists(OutFile))
{ {
string errtext = String.Empty; string errtext = String.Empty;
errtext += "No compile error. But not able to locate compiled file."; errtext += "No compile error. But not able to locate compiled file.";
throw new Exception(errtext); throw new Exception(errtext);
} }
FileInfo fi = new FileInfo(OutFile); FileInfo fi = new FileInfo(OutFile);
Byte[] data = new Byte[fi.Length]; Byte[] data = new Byte[fi.Length];
try try
{ {
FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read);
fs.Read(data, 0, data.Length); fs.Read(data, 0, data.Length);
fs.Close(); fs.Close();
} }
catch (IOException) catch (IOException)
{ {
string errtext = String.Empty; string errtext = String.Empty;
errtext += "No compile error. But not able to open file."; errtext += "No compile error. But not able to open file.";
throw new Exception(errtext); throw new Exception(errtext);
} }
// Convert to base64 // Convert to base64
// //
string filetext = Convert.ToBase64String(data); string filetext = Convert.ToBase64String(data);
ASCIIEncoding enc = new ASCIIEncoding(); ASCIIEncoding enc = new ASCIIEncoding();
Byte[] buf = enc.GetBytes(filetext); Byte[] buf = enc.GetBytes(filetext);
FileStream sfs = File.Create(OutFile + ".cil.b64"); FileStream sfs = File.Create(OutFile + ".cil.b64");
sfs.Write(buf, 0, buf.Length); sfs.Write(buf, 0, buf.Length);
sfs.Close(); sfs.Close();
return OutFile; return OutFile;
} }
} }
} }

View File

@ -1,317 +1,317 @@
using System.Collections.Generic; using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
class SOPObject : IObject class SOPObject : IObject
{ {
private readonly Scene m_rootScene; private readonly Scene m_rootScene;
private readonly uint m_localID; private readonly uint m_localID;
public SOPObject(Scene rootScene, uint localID) public SOPObject(Scene rootScene, uint localID)
{ {
m_rootScene = rootScene; m_rootScene = rootScene;
m_localID = localID; m_localID = localID;
} }
/// <summary> /// <summary>
/// This needs to run very, very quickly. /// This needs to run very, very quickly.
/// It is utilized in nearly every property and method. /// It is utilized in nearly every property and method.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private SceneObjectPart GetSOP() private SceneObjectPart GetSOP()
{ {
if (m_rootScene.Entities.ContainsKey(m_localID)) if (m_rootScene.Entities.ContainsKey(m_localID))
return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart;
return null; return null;
} }
public bool Exists public bool Exists
{ {
get { return GetSOP() != null; } get { return GetSOP() != null; }
} }
public uint LocalID public uint LocalID
{ {
get { return m_localID; } get { return m_localID; }
} }
public UUID GlobalID public UUID GlobalID
{ {
get { return GetSOP().UUID; } get { return GetSOP().UUID; }
} }
public IObject[] Children public IObject[] Children
{ {
get get
{ {
SceneObjectPart my = GetSOP(); SceneObjectPart my = GetSOP();
int total = my.ParentGroup.Children.Count; int total = my.ParentGroup.Children.Count;
IObject[] rets = new IObject[total]; IObject[] rets = new IObject[total];
int i = 0; int i = 0;
foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
{ {
rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId);
} }
return rets; return rets;
} }
} }
public IObject Root public IObject Root
{ {
get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); }
} }
public IObjectFace[] Faces public IObjectFace[] Faces
{ {
get get
{ {
SceneObjectPart sop = GetSOP(); SceneObjectPart sop = GetSOP();
IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)];
for (int i = 0; i < rets.Length;i++ ) for (int i = 0; i < rets.Length;i++ )
{ {
//rets[i] = new ObjectFace //rets[i] = new ObjectFace
} }
return rets; return rets;
} }
} }
public Vector3 Scale public Vector3 Scale
{ {
get { return GetSOP().Scale; } get { return GetSOP().Scale; }
set { GetSOP().Scale = value; } set { GetSOP().Scale = value; }
} }
public Quaternion Rotation public Quaternion Rotation
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public Vector3 SitTarget public Vector3 SitTarget
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public string SitTargetText public string SitTargetText
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public string TouchText public string TouchText
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public string Text public string Text
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsPhysical public bool IsPhysical
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsPhantom public bool IsPhantom
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsRotationLockedX public bool IsRotationLockedX
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsRotationLockedY public bool IsRotationLockedY
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsRotationLockedZ public bool IsRotationLockedZ
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsSandboxed public bool IsSandboxed
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsImmotile public bool IsImmotile
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsAlwaysReturned public bool IsAlwaysReturned
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsTemporary public bool IsTemporary
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public bool IsFlexible public bool IsFlexible
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public PrimType PrimShape public PrimType PrimShape
{ {
get { return (PrimType) getScriptPrimType(GetSOP().Shape); } get { return (PrimType) getScriptPrimType(GetSOP().Shape); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
public Material Material public Material Material
{ {
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
#region Supporting Functions #region Supporting Functions
// Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
out bool hasDimple, out bool hasProfileCut) out bool hasDimple, out bool hasProfileCut)
{ {
if (primType == (int)PrimType.Box if (primType == (int)PrimType.Box
|| ||
primType == (int)PrimType.Cylinder primType == (int)PrimType.Cylinder
|| ||
primType == (int)PrimType.Prism) primType == (int)PrimType.Prism)
hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
else else
hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
hasHollow = shape.ProfileHollow > 0; hasHollow = shape.ProfileHollow > 0;
hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
hasProfileCut = hasDimple; // is it the same thing? hasProfileCut = hasDimple; // is it the same thing?
} }
private static int getScriptPrimType(PrimitiveBaseShape primShape) private static int getScriptPrimType(PrimitiveBaseShape primShape)
{ {
if (primShape.SculptEntry) if (primShape.SculptEntry)
return (int) PrimType.Sculpt; return (int) PrimType.Sculpt;
if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
{ {
if (primShape.PathCurve == (byte) Extrusion.Straight) if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Box; return (int) PrimType.Box;
if (primShape.PathCurve == (byte) Extrusion.Curve1) if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Tube; return (int) PrimType.Tube;
} }
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle)
{ {
if (primShape.PathCurve == (byte) Extrusion.Straight) if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Cylinder; return (int) PrimType.Cylinder;
if (primShape.PathCurve == (byte) Extrusion.Curve1) if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Torus; return (int) PrimType.Torus;
} }
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle)
{ {
if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
return (int) PrimType.Sphere; return (int) PrimType.Sphere;
} }
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle)
{ {
if (primShape.PathCurve == (byte) Extrusion.Straight) if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Prism; return (int) PrimType.Prism;
if (primShape.PathCurve == (byte) Extrusion.Curve1) if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Ring; return (int) PrimType.Ring;
} }
return (int) PrimType.NotPrimitive; return (int) PrimType.NotPrimitive;
} }
private static int getNumberOfSides(SceneObjectPart part) private static int getNumberOfSides(SceneObjectPart part)
{ {
int ret; int ret;
bool hasCut; bool hasCut;
bool hasHollow; bool hasHollow;
bool hasDimple; bool hasDimple;
bool hasProfileCut; bool hasProfileCut;
int primType = getScriptPrimType(part.Shape); int primType = getScriptPrimType(part.Shape);
hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
switch (primType) switch (primType)
{ {
default: default:
case (int) PrimType.Box: case (int) PrimType.Box:
ret = 6; ret = 6;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Cylinder: case (int) PrimType.Cylinder:
ret = 3; ret = 3;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Prism: case (int) PrimType.Prism:
ret = 5; ret = 5;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Sphere: case (int) PrimType.Sphere:
ret = 1; ret = 1;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasDimple) ret += 2; if (hasDimple) ret += 2;
if (hasHollow) if (hasHollow)
ret += 1; // GOTCHA: LSL shows 2 additional sides here. ret += 1; // GOTCHA: LSL shows 2 additional sides here.
// This has been fixed, but may cause porting issues. // This has been fixed, but may cause porting issues.
break; break;
case (int) PrimType.Torus: case (int) PrimType.Torus:
ret = 1; ret = 1;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasProfileCut) ret += 2; if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Tube: case (int) PrimType.Tube:
ret = 4; ret = 4;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasProfileCut) ret += 2; if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Ring: case (int) PrimType.Ring:
ret = 3; ret = 3;
if (hasCut) ret += 2; if (hasCut) ret += 2;
if (hasProfileCut) ret += 2; if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case (int) PrimType.Sculpt: case (int) PrimType.Sculpt:
ret = 1; ret = 1;
break; break;
} }
return ret; return ret;
} }
#endregion #endregion
} }
} }

View File

@ -1,39 +1,39 @@
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public class World : IWorld public class World : IWorld
{ {
private readonly Scene m_internalScene; private readonly Scene m_internalScene;
private readonly Heightmap m_heights; private readonly Heightmap m_heights;
public World(Scene internalScene) public World(Scene internalScene)
{ {
m_internalScene = internalScene; m_internalScene = internalScene;
m_heights = new Heightmap(m_internalScene); m_heights = new Heightmap(m_internalScene);
} }
public IObject[] Objects public IObject[] Objects
{ {
get get
{ {
List<EntityBase> ents = m_internalScene.Entities.GetAllByType<SceneObjectGroup>(); List<EntityBase> ents = m_internalScene.Entities.GetAllByType<SceneObjectGroup>();
IObject[] rets = new IObject[ents.Count]; IObject[] rets = new IObject[ents.Count];
for (int i = 0; i < ents.Count; i++) for (int i = 0; i < ents.Count; i++)
{ {
EntityBase ent = ents[i]; EntityBase ent = ents[i];
rets[i] = new SOPObject(m_internalScene, ent.LocalId); rets[i] = new SOPObject(m_internalScene, ent.LocalId);
} }
return rets; return rets;
} }
} }
public IHeightmap Terrain public IHeightmap Terrain
{ {
get { return m_heights; } get { return m_heights; }
} }
} }
} }

View File

@ -1,15 +1,15 @@
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.ObjectModules namespace OpenSim.Region.OptionalModules.Scripting.ObjectModules
{ {
interface IObjectModule interface IObjectModule
{ {
void Add(EntityBase entity, Scene scene); void Add(EntityBase entity, Scene scene);
void Start(); void Start();
void Stop(); void Stop();
void Tick(); void Tick();
string ClassName { get; } string ClassName { get; }
bool IsShared { get; } bool IsShared { get; }
} }
} }