From c062138dad42ef7e52bbcb27c346ddecab94c5af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Apr 2011 12:23:40 -0700 Subject: Moved several cap-based-service-providing modules from where they were into a newly created CoreModules/Caps. Not all. --- .../CoreModules/Caps/ObjectCaps/ObjectAdd.cs | 370 ++++++++++++++++++++ .../Caps/ObjectCaps/UploadObjectAssetModule.cs | 374 +++++++++++++++++++++ 2 files changed, 744 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Caps/ObjectCaps/ObjectAdd.cs create mode 100644 OpenSim/Region/CoreModules/Caps/ObjectCaps/UploadObjectAssetModule.cs (limited to 'OpenSim/Region/CoreModules/Caps/ObjectCaps') diff --git a/OpenSim/Region/CoreModules/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/CoreModules/Caps/ObjectCaps/ObjectAdd.cs new file mode 100644 index 0000000..5cd0fe7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Caps/ObjectCaps/ObjectAdd.cs @@ -0,0 +1,370 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Caps=OpenSim.Framework.Capabilities.Caps; + +namespace OpenSim.Region.CoreModules.Capabilities +{ + public class ObjectAdd : IRegionModule + { +// private static readonly ILog m_log = +// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + #region IRegionModule Members + + public void Initialise(Scene pScene, IConfigSource pSource) + { + m_scene = pScene; + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + public void PostInitialise() + { + + } + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capuuid = UUID.Random(); + +// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); + + caps.RegisterHandler("ObjectAdd", + new RestHTTPHandler("POST", "/CAPS/OA/" + capuuid + "/", + delegate(Hashtable m_dhttpMethod) + { + return ProcessAdd(m_dhttpMethod, agentID, caps); + })); + } + + public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) + { + Hashtable responsedata = new Hashtable(); + responsedata["int_response_code"] = 400; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Request wasn't what was expected"; + ScenePresence avatar; + + if (!m_scene.TryGetScenePresence(AgentId, out avatar)) + return responsedata; + + + OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]); + //UUID session_id = UUID.Zero; + bool bypass_raycast = false; + uint everyone_mask = 0; + uint group_mask = 0; + uint next_owner_mask = 0; + uint flags = 0; + UUID group_id = UUID.Zero; + int hollow = 0; + int material = 0; + int p_code = 0; + int path_begin = 0; + int path_curve = 0; + int path_end = 0; + int path_radius_offset = 0; + int path_revolutions = 0; + int path_scale_x = 0; + int path_scale_y = 0; + int path_shear_x = 0; + int path_shear_y = 0; + int path_skew = 0; + int path_taper_x = 0; + int path_taper_y = 0; + int path_twist = 0; + int path_twist_begin = 0; + int profile_begin = 0; + int profile_curve = 0; + int profile_end = 0; + Vector3 ray_end = Vector3.Zero; + bool ray_end_is_intersection = false; + Vector3 ray_start = Vector3.Zero; + UUID ray_target_id = UUID.Zero; + Quaternion rotation = Quaternion.Identity; + Vector3 scale = Vector3.Zero; + int state = 0; + + if (r.Type != OSDType.Map) // not a proper req + return responsedata; + + OSDMap rm = (OSDMap)r; + + if (rm.ContainsKey("ObjectData")) //v2 + { + if (rm["ObjectData"].Type != OSDType.Map) + { + responsedata["str_response_string"] = "Has ObjectData key, but data not in expected format"; + return responsedata; + } + + OSDMap ObjMap = (OSDMap) rm["ObjectData"]; + + bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); + everyone_mask = readuintval(ObjMap["EveryoneMask"]); + flags = readuintval(ObjMap["Flags"]); + group_mask = readuintval(ObjMap["GroupMask"]); + material = ObjMap["Material"].AsInteger(); + next_owner_mask = readuintval(ObjMap["NextOwnerMask"]); + p_code = ObjMap["PCode"].AsInteger(); + + if (ObjMap.ContainsKey("Path")) + { + if (ObjMap["Path"].Type != OSDType.Map) + { + responsedata["str_response_string"] = "Has Path key, but data not in expected format"; + return responsedata; + } + + OSDMap PathMap = (OSDMap)ObjMap["Path"]; + path_begin = PathMap["Begin"].AsInteger(); + path_curve = PathMap["Curve"].AsInteger(); + path_end = PathMap["End"].AsInteger(); + path_radius_offset = PathMap["RadiusOffset"].AsInteger(); + path_revolutions = PathMap["Revolutions"].AsInteger(); + path_scale_x = PathMap["ScaleX"].AsInteger(); + path_scale_y = PathMap["ScaleY"].AsInteger(); + path_shear_x = PathMap["ShearX"].AsInteger(); + path_shear_y = PathMap["ShearY"].AsInteger(); + path_skew = PathMap["Skew"].AsInteger(); + path_taper_x = PathMap["TaperX"].AsInteger(); + path_taper_y = PathMap["TaperY"].AsInteger(); + path_twist = PathMap["Twist"].AsInteger(); + path_twist_begin = PathMap["TwistBegin"].AsInteger(); + + } + + if (ObjMap.ContainsKey("Profile")) + { + if (ObjMap["Profile"].Type != OSDType.Map) + { + responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; + return responsedata; + } + + OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; + + profile_begin = ProfileMap["Begin"].AsInteger(); + profile_curve = ProfileMap["Curve"].AsInteger(); + profile_end = ProfileMap["End"].AsInteger(); + hollow = ProfileMap["Hollow"].AsInteger(); + } + ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean(); + + ray_target_id = ObjMap["RayTargetId"].AsUUID(); + state = ObjMap["State"].AsInteger(); + try + { + ray_end = ((OSDArray) ObjMap["RayEnd"]).AsVector3(); + ray_start = ((OSDArray) ObjMap["RayStart"]).AsVector3(); + scale = ((OSDArray) ObjMap["Scale"]).AsVector3(); + rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion(); + } + catch (Exception) + { + responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; + return responsedata; + } + + if (rm.ContainsKey("AgentData")) + { + if (rm["AgentData"].Type != OSDType.Map) + { + responsedata["str_response_string"] = "Has AgentData key, but data not in expected format"; + return responsedata; + } + + OSDMap AgentDataMap = (OSDMap) rm["AgentData"]; + + //session_id = AgentDataMap["SessionId"].AsUUID(); + group_id = AgentDataMap["GroupId"].AsUUID(); + } + + } + else + { //v1 + bypass_raycast = rm["bypass_raycast"].AsBoolean(); + + everyone_mask = readuintval(rm["everyone_mask"]); + flags = readuintval(rm["flags"]); + group_id = rm["group_id"].AsUUID(); + group_mask = readuintval(rm["group_mask"]); + hollow = rm["hollow"].AsInteger(); + material = rm["material"].AsInteger(); + next_owner_mask = readuintval(rm["next_owner_mask"]); + hollow = rm["hollow"].AsInteger(); + p_code = rm["p_code"].AsInteger(); + path_begin = rm["path_begin"].AsInteger(); + path_curve = rm["path_curve"].AsInteger(); + path_end = rm["path_end"].AsInteger(); + path_radius_offset = rm["path_radius_offset"].AsInteger(); + path_revolutions = rm["path_revolutions"].AsInteger(); + path_scale_x = rm["path_scale_x"].AsInteger(); + path_scale_y = rm["path_scale_y"].AsInteger(); + path_shear_x = rm["path_shear_x"].AsInteger(); + path_shear_y = rm["path_shear_y"].AsInteger(); + path_skew = rm["path_skew"].AsInteger(); + path_taper_x = rm["path_taper_x"].AsInteger(); + path_taper_y = rm["path_taper_y"].AsInteger(); + path_twist = rm["path_twist"].AsInteger(); + path_twist_begin = rm["path_twist_begin"].AsInteger(); + profile_begin = rm["profile_begin"].AsInteger(); + profile_curve = rm["profile_curve"].AsInteger(); + profile_end = rm["profile_end"].AsInteger(); + + ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean(); + + ray_target_id = rm["ray_target_id"].AsUUID(); + + + //session_id = rm["session_id"].AsUUID(); + state = rm["state"].AsInteger(); + try + { + ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); + ray_start = ((OSDArray)rm["ray_start"]).AsVector3(); + rotation = ((OSDArray)rm["rotation"]).AsQuaternion(); + scale = ((OSDArray)rm["scale"]).AsVector3(); + } + catch (Exception) + { + responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; + return responsedata; + } + } + + + + 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(); + + pbs.PathBegin = (ushort)path_begin; + pbs.PathCurve = (byte)path_curve; + pbs.PathEnd = (ushort)path_end; + pbs.PathRadiusOffset = (sbyte)path_radius_offset; + pbs.PathRevolutions = (byte)path_revolutions; + pbs.PathScaleX = (byte)path_scale_x; + pbs.PathScaleY = (byte)path_scale_y; + pbs.PathShearX = (byte) path_shear_x; + pbs.PathShearY = (byte)path_shear_y; + pbs.PathSkew = (sbyte)path_skew; + pbs.PathTaperX = (sbyte)path_taper_x; + pbs.PathTaperY = (sbyte)path_taper_y; + pbs.PathTwist = (sbyte)path_twist; + pbs.PathTwistBegin = (sbyte)path_twist_begin; + pbs.HollowShape = (HollowShape) hollow; + pbs.PCode = (byte)p_code; + pbs.ProfileBegin = (ushort) profile_begin; + pbs.ProfileCurve = (byte) profile_curve; + pbs.ProfileEnd = (ushort)profile_end; + pbs.Scale = scale; + pbs.State = (byte)state; + + SceneObjectGroup obj = null; ; + + if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) + { + // rez ON the ground, not IN the ground + // pos.Z += 0.25F; + + obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); + } + + + if (obj == null) + return responsedata; + + SceneObjectPart rootpart = obj.RootPart; + rootpart.Shape = pbs; + rootpart.Flags |= (PrimFlags)flags; + rootpart.EveryoneMask = everyone_mask; + rootpart.GroupID = group_id; + rootpart.GroupMask = group_mask; + rootpart.NextOwnerMask = next_owner_mask; + rootpart.Material = (byte)material; + + + + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + + responsedata["int_response_code"] = 200; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = String.Format("local_id{0}",ConvertUintToBytes(obj.LocalId)); + + return responsedata; + } + + private uint readuintval(OSD obj) + { + byte[] tmp = obj.AsBinary(); + if (BitConverter.IsLittleEndian) + Array.Reverse(tmp); + return Utils.BytesToUInt(tmp); + + } + private string ConvertUintToBytes(uint val) + { + byte[] resultbytes = Utils.UIntToBytes(val); + if (BitConverter.IsLittleEndian) + Array.Reverse(resultbytes); + return String.Format("{0}",Convert.ToBase64String(resultbytes)); + } + + public void Close() + { + + } + + public string Name + { + get { return "ObjectAddModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Caps/ObjectCaps/UploadObjectAssetModule.cs new file mode 100644 index 0000000..33bffeb --- /dev/null +++ b/OpenSim/Region/CoreModules/Caps/ObjectCaps/UploadObjectAssetModule.cs @@ -0,0 +1,374 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.IO; +using System.Web; +using Mono.Addins; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenMetaverse.Messages.Linden; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OSD = OpenMetaverse.StructuredData.OSD; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; +using OpenSim.Framework.Capabilities; +using ExtraParamType = OpenMetaverse.ExtraParamType; + +namespace OpenSim.Region.CoreModules.Capabilities +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class UploadObjectAssetModule : INonSharedRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + + #region IRegionModuleBase Members + + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Initialise(IConfigSource source) + { + + } + + public void AddRegion(Scene pScene) + { + m_scene = pScene; + } + + public void RemoveRegion(Scene scene) + { + + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { + + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "UploadObjectAssetModuleModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capID = UUID.Random(); + +// m_log.Debug("[UPLOAD OBJECT ASSET MODULE]: /CAPS/" + capID); + caps.RegisterHandler("UploadObjectAsset", + new RestHTTPHandler("POST", "/CAPS/OA/" + capID + "/", + delegate(Hashtable m_dhttpMethod) + { + return ProcessAdd(m_dhttpMethod, agentID, caps); + })); + /* + caps.RegisterHandler("NewFileAgentInventoryVariablePrice", + + new LLSDStreamhandler("POST", + "/CAPS/" + capID.ToString(), + delegate(LLSDAssetUploadRequest req) + { + return NewAgentInventoryRequest(req,agentID); + })); + */ + + } + + #endregion + + + /// + /// Parses ad request + /// + /// + /// + /// + /// + public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) + { + Hashtable responsedata = new Hashtable(); + responsedata["int_response_code"] = 400; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Request wasn't what was expected"; + ScenePresence avatar; + + if (!m_scene.TryGetScenePresence(AgentId, out avatar)) + return responsedata; + + OSDMap r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]); + UploadObjectAssetMessage message = new UploadObjectAssetMessage(); + try + { + message.Deserialize(r); + + } + catch (Exception ex) + { + m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString()); + message = null; + } + + if (message == null) + { + responsedata["int_response_code"] = 400; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = + "errorError parsing Object"; + + return responsedata; + } + + Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); + Quaternion rot = Quaternion.Identity; + Vector3 rootpos = Vector3.Zero; +// Quaternion rootrot = Quaternion.Identity; + + SceneObjectGroup rootGroup = null; + SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length]; + for (int i = 0; i < message.Objects.Length; i++) + { + UploadObjectAssetMessage.Object obj = message.Objects[i]; + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); + + if (i == 0) + { + rootpos = obj.Position; +// rootrot = obj.Rotation; + } + + // Combine the extraparams data into it's ugly blob again.... + //int bytelength = 0; + //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) + //{ + // bytelength += obj.ExtraParams[extparams].ExtraParamData.Length; + //} + //byte[] extraparams = new byte[bytelength]; + //int position = 0; + + + + //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) + //{ + // Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, + // obj.ExtraParams[extparams].ExtraParamData.Length); + // + // position += obj.ExtraParams[extparams].ExtraParamData.Length; + // } + + //pbs.ExtraParams = extraparams; + for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) + { + UploadObjectAssetMessage.Object.ExtraParam extraParam = obj.ExtraParams[extparams]; + switch ((ushort)extraParam.Type) + { + case (ushort)ExtraParamType.Sculpt: + Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0); + + pbs.SculptEntry = true; + + pbs.SculptTexture = obj.SculptID; + pbs.SculptType = (byte)sculpt.Type; + + break; + case (ushort)ExtraParamType.Flexible: + Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0); + pbs.FlexiEntry = true; + pbs.FlexiDrag = flex.Drag; + pbs.FlexiForceX = flex.Force.X; + pbs.FlexiForceY = flex.Force.Y; + pbs.FlexiForceZ = flex.Force.Z; + pbs.FlexiGravity = flex.Gravity; + pbs.FlexiSoftness = flex.Softness; + pbs.FlexiTension = flex.Tension; + pbs.FlexiWind = flex.Wind; + break; + case (ushort)ExtraParamType.Light: + Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0); + pbs.LightColorA = light.Color.A; + pbs.LightColorB = light.Color.B; + pbs.LightColorG = light.Color.G; + pbs.LightColorR = light.Color.R; + pbs.LightCutoff = light.Cutoff; + pbs.LightEntry = true; + pbs.LightFalloff = light.Falloff; + pbs.LightIntensity = light.Intensity; + pbs.LightRadius = light.Radius; + break; + case 0x40: + pbs.ReadProjectionData(extraParam.ExtraParamData, 0); + break; + + } + + + } + pbs.PathBegin = (ushort) obj.PathBegin; + pbs.PathCurve = (byte) obj.PathCurve; + pbs.PathEnd = (ushort) obj.PathEnd; + pbs.PathRadiusOffset = (sbyte) obj.RadiusOffset; + pbs.PathRevolutions = (byte) obj.Revolutions; + pbs.PathScaleX = (byte) obj.ScaleX; + pbs.PathScaleY = (byte) obj.ScaleY; + pbs.PathShearX = (byte) obj.ShearX; + pbs.PathShearY = (byte) obj.ShearY; + pbs.PathSkew = (sbyte) obj.Skew; + pbs.PathTaperX = (sbyte) obj.TaperX; + pbs.PathTaperY = (sbyte) obj.TaperY; + pbs.PathTwist = (sbyte) obj.Twist; + pbs.PathTwistBegin = (sbyte) obj.TwistBegin; + pbs.HollowShape = (HollowShape) obj.ProfileHollow; + pbs.PCode = (byte) PCode.Prim; + pbs.ProfileBegin = (ushort) obj.ProfileBegin; + pbs.ProfileCurve = (byte) obj.ProfileCurve; + pbs.ProfileEnd = (ushort) obj.ProfileEnd; + pbs.Scale = obj.Scale; + pbs.State = (byte) 0; + SceneObjectPart prim = new SceneObjectPart(); + prim.UUID = UUID.Random(); + prim.CreatorID = AgentId; + prim.OwnerID = AgentId; + prim.GroupID = obj.GroupID; + prim.LastOwnerID = prim.OwnerID; + prim.CreationDate = Util.UnixTimeSinceEpoch(); + prim.Name = obj.Name; + prim.Description = ""; + + prim.PayPrice[0] = -2; + prim.PayPrice[1] = -2; + prim.PayPrice[2] = -2; + prim.PayPrice[3] = -2; + prim.PayPrice[4] = -2; + Primitive.TextureEntry tmp = + new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); + + for (int j = 0; j < obj.Faces.Length; j++) + { + UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; + + Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j); + + primFace.Bump = face.Bump; + primFace.RGBA = face.Color; + primFace.Fullbright = face.Fullbright; + primFace.Glow = face.Glow; + primFace.TextureID = face.ImageID; + primFace.Rotation = face.ImageRot; + primFace.MediaFlags = ((face.MediaFlags & 1) != 0); + + primFace.OffsetU = face.OffsetS; + primFace.OffsetV = face.OffsetT; + primFace.RepeatU = face.ScaleS; + primFace.RepeatV = face.ScaleT; + primFace.TexMapType = (MappingType) (face.MediaFlags & 6); + } + pbs.TextureEntry = tmp.GetBytes(); + prim.Shape = pbs; + prim.Scale = obj.Scale; + + + SceneObjectGroup grp = new SceneObjectGroup(); + + grp.SetRootPart(prim); + prim.ParentID = 0; + if (i == 0) + { + rootGroup = grp; + + } + grp.AttachToScene(m_scene); + grp.AbsolutePosition = obj.Position; + prim.RotationOffset = obj.Rotation; + + grp.RootPart.IsAttachment = false; + // Required for linking + grp.RootPart.UpdateFlag = 0; + + if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) + { + m_scene.AddSceneObject(grp); + grp.AbsolutePosition = obj.Position; + } + allparts[i] = grp; + + } + + for (int j = 1; j < allparts.Length; j++) + { + rootGroup.RootPart.UpdateFlag = 0; + allparts[j].RootPart.UpdateFlag = 0; + rootGroup.LinkToGroup(allparts[j]); + } + + rootGroup.ScheduleGroupForFullUpdate(); + pos = m_scene.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale(), false); + + responsedata["int_response_code"] = 200; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = String.Format("local_id{0}", ConvertUintToBytes(allparts[0].LocalId)); + + return responsedata; + } + + private string ConvertUintToBytes(uint val) + { + byte[] resultbytes = Utils.UIntToBytes(val); + if (BitConverter.IsLittleEndian) + Array.Reverse(resultbytes); + return String.Format("{0}", Convert.ToBase64String(resultbytes)); + } + } +} \ No newline at end of file -- cgit v1.1