aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2009-02-05 06:44:46 +0000
committerTeravus Ovares2009-02-05 06:44:46 +0000
commit8f31210432ba5a35791e1c257487c786a0a7dc14 (patch)
tree850361940ee6b0cc23be053681d3db226753c236 /OpenSim
parent* minor: remove deprecated and unused terrain method from SceneManager (diff)
downloadopensim-SC_OLD-8f31210432ba5a35791e1c257487c786a0a7dc14.zip
opensim-SC_OLD-8f31210432ba5a35791e1c257487c786a0a7dc14.tar.gz
opensim-SC_OLD-8f31210432ba5a35791e1c257487c786a0a7dc14.tar.bz2
opensim-SC_OLD-8f31210432ba5a35791e1c257487c786a0a7dc14.tar.xz
* Committing an experimental ObjectAdd module. Intended to work with http://jira.secondlife.com/browse/VWR-8049 .
* Catherine contacted us and gave us a LLSD dump to study for implementation. * Still needs to be tested. May not produce expected results.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/ObjectCaps/ObjectAdd.cs260
1 files changed, 260 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/Environment/Modules/Avatar/ObjectCaps/ObjectAdd.cs
new file mode 100644
index 0000000..fd41146
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Avatar/ObjectCaps/ObjectAdd.cs
@@ -0,0 +1,260 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenMetaverse.StructuredData;
35using OpenSim.Framework;
36using OpenSim.Framework.Servers;
37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes;
39using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
40
41namespace OpenSim.Region.Environment.Modules.Avatar.ObjectCaps
42{
43 public class ObjectAdd : IRegionModule
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private Scene m_scene;
48 #region IRegionModule Members
49
50 public void Initialise(Scene pScene, IConfigSource pSource)
51 {
52 m_scene = pScene;
53 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
54 }
55
56 public void PostInitialise()
57 {
58
59 }
60
61 public void RegisterCaps(UUID agentID, Caps caps)
62 {
63 UUID capuuid = UUID.Random();
64
65 //m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/");
66
67 caps.RegisterHandler("ObjectAdd",
68 new RestHTTPHandler("POST", "/CAPS/OA/" + capuuid + "/",
69 delegate(Hashtable m_dhttpMethod)
70 {
71 return ProcessAdd(m_dhttpMethod, agentID, caps);
72 }));
73 }
74
75 public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
76 {
77 Hashtable responsedata = new Hashtable();
78 responsedata["int_response_code"] = 400; //501; //410; //404;
79 responsedata["content_type"] = "text/plain";
80 responsedata["keepalive"] = false;
81 responsedata["str_response_string"] = "Request wasn't what was expected";
82 ScenePresence avatar;
83
84 if (!m_scene.TryGetAvatar(AgentId, out avatar))
85 return responsedata;
86
87
88 OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]);
89 UUID session_id = UUID.Zero;
90 bool bypass_raycast = false;
91 uint everyone_mask = 0;
92 uint group_mask = 0;
93 uint next_owner_mask = 0;
94 uint flags = 0;
95 UUID group_id;
96 int hollow = 0;
97 int material = 0;
98 int p_code = 0;
99 int path_begin = 0;
100 int path_curve = 0;
101 int path_end = 0;
102 int path_radius_offset = 0;
103 int path_revolutions = 0;
104 int path_scale_x = 0;
105 int path_scale_y = 0;
106 int path_shear_x = 0;
107 int path_shear_y = 0;
108 int path_skew = 0;
109 int path_taper_x = 0;
110 int path_taper_y = 0;
111 int path_twist = 0;
112 int path_twist_begin = 0;
113 int profile_begin = 0;
114 int profile_curve = 0;
115 int profile_end = 0;
116 Vector3 ray_end = Vector3.Zero;
117 bool ray_end_is_intersection = false;
118 Vector3 ray_start = Vector3.Zero;
119 UUID ray_target_id = UUID.Zero;
120 Quaternion rotation = Quaternion.Identity;
121 Vector3 scale = Vector3.Zero;
122 int state = 0;
123
124 if (r.Type != OSDType.Map) // not a proper req
125 return responsedata;
126
127 OSDMap rm = (OSDMap)r;
128
129 bypass_raycast = rm["bypass_raycast"].AsBoolean();
130
131 everyone_mask = readuintval(rm["everyone_mask"]);
132 flags = readuintval(rm["flags"]);
133 group_id = rm["group_id"].AsUUID();
134 group_mask = readuintval(rm["group_mask"]);
135 hollow = rm["hollow"].AsInteger();
136 material = rm["material"].AsInteger();
137 next_owner_mask = readuintval(rm["next_owner_mask"]);
138 hollow = rm["hollow"].AsInteger();
139 p_code= rm["p_code"].AsInteger();
140 path_begin = rm["path_begin"].AsInteger();
141 path_curve = rm["path_curve"].AsInteger();
142 path_end = rm["path_end"].AsInteger();
143 path_radius_offset = rm["path_radius_offset"].AsInteger();
144 path_revolutions = rm["path_revolutions"].AsInteger();
145 path_scale_x = rm["path_scale_x"].AsInteger();
146 path_scale_y = rm["path_scale_y"].AsInteger();
147 path_shear_x = rm["path_shear_x"].AsInteger();
148 path_shear_y = rm["path_shear_y"].AsInteger();
149 path_skew = rm["path_skew"].AsInteger();
150 path_taper_x = rm["path_taper_x"].AsInteger();
151 path_taper_y = rm["path_taper_y"].AsInteger();
152 path_twist = rm["path_twist"].AsInteger();
153 path_twist_begin = rm["path_twist_begin"].AsInteger();
154 profile_begin = rm["profile_begin"].AsInteger();
155 profile_curve = rm["profile_curve"].AsInteger();
156 profile_end = rm["profile_end"].AsInteger();
157 ray_end = ((OSDArray) rm["ray_end"]).AsVector3();
158 ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean();
159 ray_start = ((OSDArray) rm["ray_start"]).AsVector3();
160 ray_target_id = rm["ray_target_id"].AsUUID();
161 rotation = ((OSDArray) rm["rotation"]).AsQuaternion();
162 scale = ((OSDArray)rm["scale"]).AsVector3();
163 session_id = rm["session_id"].AsUUID();
164 state = rm["state"].AsInteger();
165
166 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);
167
168 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
169
170 pbs.PathBegin = (ushort)path_begin;
171 pbs.PathCurve = (byte)path_curve;
172 pbs.PathEnd = (ushort)path_end;
173 pbs.PathRadiusOffset = (sbyte)path_radius_offset;
174 pbs.PathRevolutions = (byte)path_revolutions;
175 pbs.PathScaleX = (byte)path_scale_x;
176 pbs.PathScaleY = (byte)path_scale_y;
177 pbs.PathShearX = (byte) path_shear_x;
178 pbs.PathShearY = (byte)path_shear_y;
179 pbs.PathSkew = (sbyte)path_skew;
180 pbs.PathTaperX = (sbyte)path_taper_x;
181 pbs.PathTaperY = (sbyte)path_taper_y;
182 pbs.PathTwist = (sbyte)path_twist;
183 pbs.PathTwistBegin = (sbyte)path_twist_begin;
184 pbs.HollowShape = (HollowShape) hollow;
185 pbs.PCode = (byte)p_code;
186 pbs.ProfileBegin = (ushort) profile_begin;
187 pbs.ProfileCurve = (byte) profile_curve;
188 pbs.ProfileEnd = (ushort)profile_end;
189 pbs.Scale = scale;
190 pbs.State = (byte)state;
191
192 SceneObjectGroup obj = null; ;
193
194 if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
195 {
196 // rez ON the ground, not IN the ground
197 pos.Z += 0.25F;
198
199 obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
200 }
201
202
203 if (obj == null)
204 return responsedata;
205
206 SceneObjectPart rootpart = obj.RootPart;
207 rootpart.Shape = pbs;
208 rootpart.Flags |= (PrimFlags)flags;
209 rootpart.EveryoneMask = everyone_mask;
210 rootpart.GroupID = group_id;
211 rootpart.GroupMask = group_mask;
212 rootpart.NextOwnerMask = next_owner_mask;
213 rootpart.Material = (byte)material;
214
215
216
217 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
218
219 responsedata["int_response_code"] = 200; //501; //410; //404;
220 responsedata["content_type"] = "text/plain";
221 responsedata["keepalive"] = false;
222 responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>",ConvertUintToBytes(obj.LocalId));
223
224 return responsedata;
225 }
226
227 private uint readuintval(OSD obj)
228 {
229 byte[] tmp = obj.AsBinary();
230 if (BitConverter.IsLittleEndian)
231 Array.Reverse(tmp);
232 return Utils.BytesToUInt(tmp);
233
234 }
235 private string ConvertUintToBytes(uint val)
236 {
237 byte[] resultbytes = Utils.UIntToBytes(val);
238 if (BitConverter.IsLittleEndian)
239 Array.Reverse(resultbytes);
240 return String.Format("<binary encoding=\"base64\">{0}</binary>",Convert.ToBase64String(resultbytes));
241 }
242
243 public void Close()
244 {
245
246 }
247
248 public string Name
249 {
250 get { return "ObjectAddModule"; }
251 }
252
253 public bool IsSharedModule
254 {
255 get { return false; }
256 }
257
258 #endregion
259 }
260}