aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2010-10-19 01:53:56 -0400
committerTeravus Ovares (Dan Olivares)2010-10-19 01:53:56 -0400
commitb2c1a1c9bd7a6673eda618b39124f28ccf10e7bf (patch)
treec6ab2bbdfd7491bb3f2ce174d9b9703afa9a7bc3
parent* Almost complete implementation of UploadObjectAsset cap. all meshes get u... (diff)
downloadopensim-SC_OLD-b2c1a1c9bd7a6673eda618b39124f28ccf10e7bf.zip
opensim-SC_OLD-b2c1a1c9bd7a6673eda618b39124f28ccf10e7bf.tar.gz
opensim-SC_OLD-b2c1a1c9bd7a6673eda618b39124f28ccf10e7bf.tar.bz2
opensim-SC_OLD-b2c1a1c9bd7a6673eda618b39124f28ccf10e7bf.tar.xz
* This concludes UploadObjectAsset for now until the permissions and physics shape are added to the message serialization.
* You should now be able to upload multiple mesh collada mesh objects. They should appear in front of you (or on top of you!) when you upload them. * Once again, thanks to John Hurliman and Latif Khalifa for insight and smxy for cheering me on :D
-rw-r--r--OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs124
1 files changed, 76 insertions, 48 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs
index f1f219b..d5c6e9d 100644
--- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs
@@ -126,6 +126,14 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
126 126
127 #endregion 127 #endregion
128 128
129
130 /// <summary>
131 /// Parses ad request
132 /// </summary>
133 /// <param name="request"></param>
134 /// <param name="AgentId"></param>
135 /// <param name="cap"></param>
136 /// <returns></returns>
129 public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) 137 public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
130 { 138 {
131 Hashtable responsedata = new Hashtable(); 139 Hashtable responsedata = new Hashtable();
@@ -147,9 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
147 } 155 }
148 catch (Exception ex) 156 catch (Exception ex)
149 { 157 {
150 m_log.Error("[UploadObjectAssetModule]: Error deserializing message"); 158 m_log.Error("[UploadObjectAssetModule]: Error deserializing message " + ex.ToString());
151 // TODO: Remove this ugly multiline-friendly debug!
152 Console.WriteLine(ex.ToString());
153 message = null; 159 message = null;
154 } 160 }
155 161
@@ -163,18 +169,25 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
163 169
164 return responsedata; 170 return responsedata;
165 } 171 }
166 172
167 Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); 173 Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation);
168 Quaternion rot = Quaternion.Identity; 174 Quaternion rot = Quaternion.Identity;
175 Vector3 rootpos = Vector3.Zero;
176 Quaternion rootrot = Quaternion.Identity;
169 177
170 178 SceneObjectGroup rootGroup = null;
171 179 SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length];
172 SceneObjectGroup grp = new SceneObjectGroup();
173 for (int i = 0; i < message.Objects.Length; i++) 180 for (int i = 0; i < message.Objects.Length; i++)
174 { 181 {
175 UploadObjectAssetMessage.Object obj = message.Objects[i]; 182 UploadObjectAssetMessage.Object obj = message.Objects[i];
176 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 183 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
177 184
185 if (i == 0)
186 {
187 rootpos = obj.Position;
188 rootrot = obj.Rotation;
189
190 }
178 // Combine the extraparams data into it's ugly blob again.... 191 // Combine the extraparams data into it's ugly blob again....
179 int bytelength = 0; 192 int bytelength = 0;
180 for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) 193 for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
@@ -186,34 +199,35 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
186 199
187 for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) 200 for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
188 { 201 {
189 Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, obj.ExtraParams[extparams].ExtraParamData.Length); 202 Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position,
203 obj.ExtraParams[extparams].ExtraParamData.Length);
190 204
191 position += obj.ExtraParams[extparams].ExtraParamData.Length; 205 position += obj.ExtraParams[extparams].ExtraParamData.Length;
192 } 206 }
193 207
194 pbs.ExtraParams = extraparams; 208 pbs.ExtraParams = extraparams;
195 209
196 pbs.PathBegin = (ushort)obj.PathBegin; 210 pbs.PathBegin = (ushort) obj.PathBegin;
197 pbs.PathCurve = (byte)obj.PathCurve; 211 pbs.PathCurve = (byte) obj.PathCurve;
198 pbs.PathEnd = (ushort)obj.PathEnd; 212 pbs.PathEnd = (ushort) obj.PathEnd;
199 pbs.PathRadiusOffset = (sbyte)obj.RadiusOffset; 213 pbs.PathRadiusOffset = (sbyte) obj.RadiusOffset;
200 pbs.PathRevolutions = (byte)obj.Revolutions; 214 pbs.PathRevolutions = (byte) obj.Revolutions;
201 pbs.PathScaleX = (byte)obj.ScaleX; 215 pbs.PathScaleX = (byte) obj.ScaleX;
202 pbs.PathScaleY = (byte)obj.ScaleY; 216 pbs.PathScaleY = (byte) obj.ScaleY;
203 pbs.PathShearX = (byte)obj.ShearX; 217 pbs.PathShearX = (byte) obj.ShearX;
204 pbs.PathShearY = (byte)obj.ShearY; 218 pbs.PathShearY = (byte) obj.ShearY;
205 pbs.PathSkew = (sbyte)obj.Skew; 219 pbs.PathSkew = (sbyte) obj.Skew;
206 pbs.PathTaperX = (sbyte)obj.TaperX; 220 pbs.PathTaperX = (sbyte) obj.TaperX;
207 pbs.PathTaperY = (sbyte)obj.TaperY; 221 pbs.PathTaperY = (sbyte) obj.TaperY;
208 pbs.PathTwist = (sbyte)obj.Twist; 222 pbs.PathTwist = (sbyte) obj.Twist;
209 pbs.PathTwistBegin = (sbyte)obj.TwistBegin; 223 pbs.PathTwistBegin = (sbyte) obj.TwistBegin;
210 pbs.HollowShape = (HollowShape)obj.ProfileHollow; 224 pbs.HollowShape = (HollowShape) obj.ProfileHollow;
211 pbs.PCode = (byte)PCode.Prim; 225 pbs.PCode = (byte) PCode.Prim;
212 pbs.ProfileBegin = (ushort)obj.ProfileBegin; 226 pbs.ProfileBegin = (ushort) obj.ProfileBegin;
213 pbs.ProfileCurve = (byte)obj.ProfileCurve; 227 pbs.ProfileCurve = (byte) obj.ProfileCurve;
214 pbs.ProfileEnd = (ushort)obj.ProfileEnd; 228 pbs.ProfileEnd = (ushort) obj.ProfileEnd;
215 pbs.Scale = obj.Scale; 229 pbs.Scale = obj.Scale;
216 pbs.State = (byte)0; 230 pbs.State = (byte) 0;
217 SceneObjectPart prim = new SceneObjectPart(); 231 SceneObjectPart prim = new SceneObjectPart();
218 prim.UUID = UUID.Random(); 232 prim.UUID = UUID.Random();
219 prim.CreatorID = AgentId; 233 prim.CreatorID = AgentId;
@@ -229,13 +243,14 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
229 prim.PayPrice[2] = -2; 243 prim.PayPrice[2] = -2;
230 prim.PayPrice[3] = -2; 244 prim.PayPrice[3] = -2;
231 prim.PayPrice[4] = -2; 245 prim.PayPrice[4] = -2;
232 Primitive.TextureEntry tmp = new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); 246 Primitive.TextureEntry tmp =
247 new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f"));
233 248
234 for (int j = 0; j < obj.Faces.Length; j++) 249 for (int j = 0; j < obj.Faces.Length; j++)
235 { 250 {
236 UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; 251 UploadObjectAssetMessage.Object.Face face = obj.Faces[j];
237 252
238 Primitive.TextureEntryFace primFace = tmp.CreateFace((uint)j); 253 Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j);
239 254
240 primFace.Bump = face.Bump; 255 primFace.Bump = face.Bump;
241 primFace.RGBA = face.Color; 256 primFace.RGBA = face.Color;
@@ -249,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
249 primFace.OffsetV = face.OffsetT; 264 primFace.OffsetV = face.OffsetT;
250 primFace.RepeatU = face.ScaleS; 265 primFace.RepeatU = face.ScaleS;
251 primFace.RepeatV = face.ScaleT; 266 primFace.RepeatV = face.ScaleT;
252 primFace.TexMapType = (MappingType)(face.MediaFlags & 6); 267 primFace.TexMapType = (MappingType) (face.MediaFlags & 6);
253 } 268 }
254 pbs.TextureEntry = tmp.GetBytes(); 269 pbs.TextureEntry = tmp.GetBytes();
255 prim.Shape = pbs; 270 prim.Shape = pbs;
@@ -257,34 +272,47 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
257 prim.Shape.SculptEntry = true; 272 prim.Shape.SculptEntry = true;
258 prim.Shape.SculptTexture = obj.SculptID; 273 prim.Shape.SculptTexture = obj.SculptID;
259 prim.Shape.SculptType = (byte) SculptType.Mesh; 274 prim.Shape.SculptType = (byte) SculptType.Mesh;
260 275
276 SceneObjectGroup grp = new SceneObjectGroup();
277
278 grp.SetRootPart(prim);
279 prim.ParentID = 0;
261 if (i == 0) 280 if (i == 0)
262 { 281 {
263 grp.SetRootPart(prim); 282 rootGroup = grp;
264 prim.ParentID = 0; 283
265 } 284 }
266 else 285 grp.AttachToScene(m_scene);
286 grp.AbsolutePosition = obj.Position;
287 prim.RotationOffset = obj.Rotation;
288
289 grp.RootPart.IsAttachment = false;
290 // Required for linking
291 grp.RootPart.UpdateFlag = 0;
292
293 if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
267 { 294 {
268 prim.SetParent(grp); 295 m_scene.AddSceneObject(grp);
269 grp.AddPart(prim); 296 grp.AbsolutePosition = obj.Position;
270 } 297 }
271 298 allparts[i] = grp;
299
272 } 300 }
273 pos = m_scene.GetNewRezLocation(Vector3.Zero, pos, UUID.Zero, rot, (byte)1 , 1 , true, grp.GroupScale(), false); 301
274 grp.AttachToScene(m_scene); 302 for (int j = 1; j < allparts.Length; j++)
275 grp.AbsolutePosition = pos;
276 grp.ClearPartAttachmentData();
277 grp.RootPart.IsAttachment = false;
278
279 if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
280 { 303 {
281 m_scene.AddSceneObject(grp); 304 rootGroup.RootPart.UpdateFlag = 0;
305 allparts[j].RootPart.UpdateFlag = 0;
306 rootGroup.LinkToGroup(allparts[j]);
282 } 307 }
283 grp.ScheduleGroupForFullUpdate(); 308
309 rootGroup.ScheduleGroupForFullUpdate();
310 pos = m_scene.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale(), false);
311
284 responsedata["int_response_code"] = 200; //501; //410; //404; 312 responsedata["int_response_code"] = 200; //501; //410; //404;
285 responsedata["content_type"] = "text/plain"; 313 responsedata["content_type"] = "text/plain";
286 responsedata["keepalive"] = false; 314 responsedata["keepalive"] = false;
287 responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(grp.LocalId)); 315 responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId));
288 316
289 return responsedata; 317 return responsedata;
290 318