One more module converted: ObjectAdd.
parent
26a94610fc
commit
3a5e317f65
|
@ -32,6 +32,7 @@ using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
|
using Mono.Addins;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
@ -41,30 +42,60 @@ using Caps=OpenSim.Framework.Capabilities.Caps;
|
||||||
|
|
||||||
namespace OpenSim.Region.ClientStack.Linden
|
namespace OpenSim.Region.ClientStack.Linden
|
||||||
{
|
{
|
||||||
public class ObjectAdd : IRegionModule
|
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
|
||||||
|
public class ObjectAdd : INonSharedRegionModule
|
||||||
{
|
{
|
||||||
// private static readonly ILog m_log =
|
// private static readonly ILog m_log =
|
||||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
#region IRegionModule Members
|
|
||||||
|
|
||||||
public void Initialise(Scene pScene, IConfigSource pSource)
|
#region INonSharedRegionModule Members
|
||||||
|
|
||||||
|
public void Initialise(IConfigSource pSource)
|
||||||
{
|
{
|
||||||
m_scene = pScene;
|
}
|
||||||
|
|
||||||
|
public void AddRegion(Scene scene)
|
||||||
|
{
|
||||||
|
m_scene = scene;
|
||||||
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
|
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
|
if (m_scene == scene)
|
||||||
|
{
|
||||||
|
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
|
||||||
|
m_scene = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegionLoaded(Scene scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "ObjectAddModule"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ReplaceableInterface
|
||||||
|
{
|
||||||
|
get { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void RegisterCaps(UUID agentID, Caps caps)
|
public void RegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
UUID capuuid = UUID.Random();
|
UUID capuuid = UUID.Random();
|
||||||
|
|
||||||
// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/");
|
// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/");
|
||||||
|
|
||||||
caps.RegisterHandler(
|
caps.RegisterHandler(
|
||||||
"ObjectAdd",
|
"ObjectAdd",
|
||||||
|
@ -73,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
"/CAPS/OA/" + capuuid + "/",
|
"/CAPS/OA/" + capuuid + "/",
|
||||||
httpMethod => ProcessAdd(httpMethod, agentID, caps),
|
httpMethod => ProcessAdd(httpMethod, agentID, caps),
|
||||||
"ObjectAdd",
|
"ObjectAdd",
|
||||||
agentID.ToString()));;
|
agentID.ToString())); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
|
public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
|
||||||
|
@ -84,7 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
responsedata["keepalive"] = false;
|
responsedata["keepalive"] = false;
|
||||||
responsedata["str_response_string"] = "Request wasn't what was expected";
|
responsedata["str_response_string"] = "Request wasn't what was expected";
|
||||||
ScenePresence avatar;
|
ScenePresence avatar;
|
||||||
|
|
||||||
if (!m_scene.TryGetScenePresence(AgentId, out avatar))
|
if (!m_scene.TryGetScenePresence(AgentId, out avatar))
|
||||||
return responsedata;
|
return responsedata;
|
||||||
|
|
||||||
|
@ -127,7 +158,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
if (r.Type != OSDType.Map) // not a proper req
|
if (r.Type != OSDType.Map) // not a proper req
|
||||||
return responsedata;
|
return responsedata;
|
||||||
|
|
||||||
OSDMap rm = (OSDMap)r;
|
OSDMap rm = (OSDMap)r;
|
||||||
|
|
||||||
if (rm.ContainsKey("ObjectData")) //v2
|
if (rm.ContainsKey("ObjectData")) //v2
|
||||||
|
@ -138,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap ObjMap = (OSDMap) rm["ObjectData"];
|
OSDMap ObjMap = (OSDMap)rm["ObjectData"];
|
||||||
|
|
||||||
bypass_raycast = ObjMap["BypassRaycast"].AsBoolean();
|
bypass_raycast = ObjMap["BypassRaycast"].AsBoolean();
|
||||||
everyone_mask = readuintval(ObjMap["EveryoneMask"]);
|
everyone_mask = readuintval(ObjMap["EveryoneMask"]);
|
||||||
|
@ -181,7 +212,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
responsedata["str_response_string"] = "Has Profile key, but data not in expected format";
|
responsedata["str_response_string"] = "Has Profile key, but data not in expected format";
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap ProfileMap = (OSDMap)ObjMap["Profile"];
|
OSDMap ProfileMap = (OSDMap)ObjMap["Profile"];
|
||||||
|
|
||||||
profile_begin = ProfileMap["Begin"].AsInteger();
|
profile_begin = ProfileMap["Begin"].AsInteger();
|
||||||
|
@ -190,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
hollow = ProfileMap["Hollow"].AsInteger();
|
hollow = ProfileMap["Hollow"].AsInteger();
|
||||||
}
|
}
|
||||||
ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean();
|
ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean();
|
||||||
|
|
||||||
ray_target_id = ObjMap["RayTargetId"].AsUUID();
|
ray_target_id = ObjMap["RayTargetId"].AsUUID();
|
||||||
state = ObjMap["State"].AsInteger();
|
state = ObjMap["State"].AsInteger();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ray_end = ((OSDArray) ObjMap["RayEnd"]).AsVector3();
|
ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3();
|
||||||
ray_start = ((OSDArray) ObjMap["RayStart"]).AsVector3();
|
ray_start = ((OSDArray)ObjMap["RayStart"]).AsVector3();
|
||||||
scale = ((OSDArray) ObjMap["Scale"]).AsVector3();
|
scale = ((OSDArray)ObjMap["Scale"]).AsVector3();
|
||||||
rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion();
|
rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -214,7 +245,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap AgentDataMap = (OSDMap) rm["AgentData"];
|
OSDMap AgentDataMap = (OSDMap)rm["AgentData"];
|
||||||
|
|
||||||
//session_id = AgentDataMap["SessionId"].AsUUID();
|
//session_id = AgentDataMap["SessionId"].AsUUID();
|
||||||
group_id = AgentDataMap["GroupId"].AsUUID();
|
group_id = AgentDataMap["GroupId"].AsUUID();
|
||||||
|
@ -251,21 +282,21 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
profile_begin = rm["profile_begin"].AsInteger();
|
profile_begin = rm["profile_begin"].AsInteger();
|
||||||
profile_curve = rm["profile_curve"].AsInteger();
|
profile_curve = rm["profile_curve"].AsInteger();
|
||||||
profile_end = rm["profile_end"].AsInteger();
|
profile_end = rm["profile_end"].AsInteger();
|
||||||
|
|
||||||
ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean();
|
ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean();
|
||||||
|
|
||||||
ray_target_id = rm["ray_target_id"].AsUUID();
|
ray_target_id = rm["ray_target_id"].AsUUID();
|
||||||
|
|
||||||
|
|
||||||
//session_id = rm["session_id"].AsUUID();
|
//session_id = rm["session_id"].AsUUID();
|
||||||
state = rm["state"].AsInteger();
|
state = rm["state"].AsInteger();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ray_end = ((OSDArray)rm["ray_end"]).AsVector3();
|
ray_end = ((OSDArray)rm["ray_end"]).AsVector3();
|
||||||
ray_start = ((OSDArray)rm["ray_start"]).AsVector3();
|
ray_start = ((OSDArray)rm["ray_start"]).AsVector3();
|
||||||
rotation = ((OSDArray)rm["rotation"]).AsQuaternion();
|
rotation = ((OSDArray)rm["rotation"]).AsQuaternion();
|
||||||
scale = ((OSDArray)rm["scale"]).AsVector3();
|
scale = ((OSDArray)rm["scale"]).AsVector3();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format";
|
responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format";
|
||||||
|
@ -273,9 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false);
|
|
||||||
|
Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false);
|
||||||
|
|
||||||
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
|
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
|
||||||
|
|
||||||
|
@ -286,17 +317,17 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
pbs.PathRevolutions = (byte)path_revolutions;
|
pbs.PathRevolutions = (byte)path_revolutions;
|
||||||
pbs.PathScaleX = (byte)path_scale_x;
|
pbs.PathScaleX = (byte)path_scale_x;
|
||||||
pbs.PathScaleY = (byte)path_scale_y;
|
pbs.PathScaleY = (byte)path_scale_y;
|
||||||
pbs.PathShearX = (byte) path_shear_x;
|
pbs.PathShearX = (byte)path_shear_x;
|
||||||
pbs.PathShearY = (byte)path_shear_y;
|
pbs.PathShearY = (byte)path_shear_y;
|
||||||
pbs.PathSkew = (sbyte)path_skew;
|
pbs.PathSkew = (sbyte)path_skew;
|
||||||
pbs.PathTaperX = (sbyte)path_taper_x;
|
pbs.PathTaperX = (sbyte)path_taper_x;
|
||||||
pbs.PathTaperY = (sbyte)path_taper_y;
|
pbs.PathTaperY = (sbyte)path_taper_y;
|
||||||
pbs.PathTwist = (sbyte)path_twist;
|
pbs.PathTwist = (sbyte)path_twist;
|
||||||
pbs.PathTwistBegin = (sbyte)path_twist_begin;
|
pbs.PathTwistBegin = (sbyte)path_twist_begin;
|
||||||
pbs.HollowShape = (HollowShape) hollow;
|
pbs.HollowShape = (HollowShape)hollow;
|
||||||
pbs.PCode = (byte)p_code;
|
pbs.PCode = (byte)p_code;
|
||||||
pbs.ProfileBegin = (ushort) profile_begin;
|
pbs.ProfileBegin = (ushort)profile_begin;
|
||||||
pbs.ProfileCurve = (byte) profile_curve;
|
pbs.ProfileCurve = (byte)profile_curve;
|
||||||
pbs.ProfileEnd = (ushort)profile_end;
|
pbs.ProfileEnd = (ushort)profile_end;
|
||||||
pbs.Scale = scale;
|
pbs.Scale = scale;
|
||||||
pbs.State = (byte)state;
|
pbs.State = (byte)state;
|
||||||
|
@ -306,7 +337,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
|
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
|
||||||
{
|
{
|
||||||
// rez ON the ground, not IN the ground
|
// rez ON the ground, not IN the ground
|
||||||
// pos.Z += 0.25F;
|
// pos.Z += 0.25F;
|
||||||
|
|
||||||
obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
|
obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
|
||||||
}
|
}
|
||||||
|
@ -323,13 +354,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
rootpart.GroupMask = group_mask;
|
rootpart.GroupMask = group_mask;
|
||||||
rootpart.NextOwnerMask = next_owner_mask;
|
rootpart.NextOwnerMask = next_owner_mask;
|
||||||
rootpart.Material = (byte)material;
|
rootpart.Material = (byte)material;
|
||||||
|
|
||||||
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
|
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
|
||||||
|
|
||||||
responsedata["int_response_code"] = 200; //501; //410; //404;
|
responsedata["int_response_code"] = 200; //501; //410; //404;
|
||||||
responsedata["content_type"] = "text/plain";
|
responsedata["content_type"] = "text/plain";
|
||||||
responsedata["keepalive"] = false;
|
responsedata["keepalive"] = false;
|
||||||
responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>",ConvertUintToBytes(obj.LocalId));
|
responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(obj.LocalId));
|
||||||
|
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
@ -347,24 +378,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
byte[] resultbytes = Utils.UIntToBytes(val);
|
byte[] resultbytes = Utils.UIntToBytes(val);
|
||||||
if (BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
Array.Reverse(resultbytes);
|
Array.Reverse(resultbytes);
|
||||||
return String.Format("<binary encoding=\"base64\">{0}</binary>",Convert.ToBase64String(resultbytes));
|
return String.Format("<binary encoding=\"base64\">{0}</binary>", Convert.ToBase64String(resultbytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "ObjectAddModule"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsSharedModule
|
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue