From 158e43d4fde8c11454b8dd605e59bf17050ac57d Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 18 Oct 2010 23:47:35 -0400 Subject: * Almost complete implementation of UploadObjectAsset cap. all meshes get uploaded but they're improperly positioned/oriented at the moment. --- .../Avatar/ObjectCaps/UploadObjectAssetModule.cs | 301 +++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs new file mode 100644 index 0000000..f1f219b --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs @@ -0,0 +1,301 @@ +/* + * 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; + +namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps +{ + [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.Info("[UploadObjectAssetModule]: /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 + + 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("[UploadObjectAssetModule]: Error deserializing message"); + // TODO: Remove this ugly multiline-friendly debug! + Console.WriteLine(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; + + + + SceneObjectGroup grp = new SceneObjectGroup(); + for (int i = 0; i < message.Objects.Length; i++) + { + UploadObjectAssetMessage.Object obj = message.Objects[i]; + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); + + // 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; + + 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; + prim.Shape.SculptEntry = true; + prim.Shape.SculptTexture = obj.SculptID; + prim.Shape.SculptType = (byte) SculptType.Mesh; + + if (i == 0) + { + grp.SetRootPart(prim); + prim.ParentID = 0; + } + else + { + prim.SetParent(grp); + grp.AddPart(prim); + } + + } + pos = m_scene.GetNewRezLocation(Vector3.Zero, pos, UUID.Zero, rot, (byte)1 , 1 , true, grp.GroupScale(), false); + grp.AttachToScene(m_scene); + grp.AbsolutePosition = pos; + grp.ClearPartAttachmentData(); + grp.RootPart.IsAttachment = false; + + if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) + { + m_scene.AddSceneObject(grp); + } + grp.ScheduleGroupForFullUpdate(); + 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(grp.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)); + } + } +} -- cgit v1.1 From b2c1a1c9bd7a6673eda618b39124f28ccf10e7bf Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 19 Oct 2010 01:53:56 -0400 Subject: * 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 --- .../Avatar/ObjectCaps/UploadObjectAssetModule.cs | 124 +++++++++++++-------- 1 file 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 #endregion + + /// + /// Parses ad request + /// + /// + /// + /// + /// public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); @@ -147,9 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps } catch (Exception ex) { - m_log.Error("[UploadObjectAssetModule]: Error deserializing message"); - // TODO: Remove this ugly multiline-friendly debug! - Console.WriteLine(ex.ToString()); + m_log.Error("[UploadObjectAssetModule]: Error deserializing message " + ex.ToString()); message = null; } @@ -163,18 +169,25 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps return responsedata; } - + Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); Quaternion rot = Quaternion.Identity; + Vector3 rootpos = Vector3.Zero; + Quaternion rootrot = Quaternion.Identity; - - - SceneObjectGroup grp = new SceneObjectGroup(); + 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++) @@ -186,34 +199,35 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) { - Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, obj.ExtraParams[extparams].ExtraParamData.Length); + Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, + obj.ExtraParams[extparams].ExtraParamData.Length); position += obj.ExtraParams[extparams].ExtraParamData.Length; } pbs.ExtraParams = extraparams; - 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.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; + pbs.State = (byte) 0; SceneObjectPart prim = new SceneObjectPart(); prim.UUID = UUID.Random(); prim.CreatorID = AgentId; @@ -229,13 +243,14 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps 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")); + 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); + Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j); primFace.Bump = face.Bump; primFace.RGBA = face.Color; @@ -249,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps primFace.OffsetV = face.OffsetT; primFace.RepeatU = face.ScaleS; primFace.RepeatV = face.ScaleT; - primFace.TexMapType = (MappingType)(face.MediaFlags & 6); + primFace.TexMapType = (MappingType) (face.MediaFlags & 6); } pbs.TextureEntry = tmp.GetBytes(); prim.Shape = pbs; @@ -257,34 +272,47 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps prim.Shape.SculptEntry = true; prim.Shape.SculptTexture = obj.SculptID; prim.Shape.SculptType = (byte) SculptType.Mesh; - + + SceneObjectGroup grp = new SceneObjectGroup(); + + grp.SetRootPart(prim); + prim.ParentID = 0; if (i == 0) { - grp.SetRootPart(prim); - prim.ParentID = 0; + rootGroup = grp; + } - else + 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)) { - prim.SetParent(grp); - grp.AddPart(prim); + m_scene.AddSceneObject(grp); + grp.AbsolutePosition = obj.Position; } - + allparts[i] = grp; + } - pos = m_scene.GetNewRezLocation(Vector3.Zero, pos, UUID.Zero, rot, (byte)1 , 1 , true, grp.GroupScale(), false); - grp.AttachToScene(m_scene); - grp.AbsolutePosition = pos; - grp.ClearPartAttachmentData(); - grp.RootPart.IsAttachment = false; - - if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) + + for (int j = 1; j < allparts.Length; j++) { - m_scene.AddSceneObject(grp); + rootGroup.RootPart.UpdateFlag = 0; + allparts[j].RootPart.UpdateFlag = 0; + rootGroup.LinkToGroup(allparts[j]); } - grp.ScheduleGroupForFullUpdate(); + + 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(grp.LocalId)); + responsedata["str_response_string"] = String.Format("local_id{0}", ConvertUintToBytes(allparts[0].LocalId)); return responsedata; -- cgit v1.1 From 684449f7832fbb6b1811c303f25d08cdfc3dd6d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Oct 2010 00:04:02 -0700 Subject: Added TextureAnimation and ParticleSystem to serialization. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 7b94a81..b6aa31b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -318,6 +318,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); + m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); + m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); #endregion #region TaskInventoryXmlProcessors initialization @@ -663,6 +665,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty); } + + private static void ProcessTextureAnimation(SceneObjectPart obj, XmlTextReader reader) + { + obj.TextureAnimation = Convert.FromBase64String(reader.ReadElementContentAsString("TextureAnimation", String.Empty)); + } + + private static void ProcessParticleSystem(SceneObjectPart obj, XmlTextReader reader) + { + obj.ParticleSystem = Convert.FromBase64String(reader.ReadElementContentAsString("ParticleSystem", String.Empty)); + } #endregion #region TaskInventoryXmlProcessors @@ -1128,6 +1140,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); if (sop.MediaUrl != null) writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); + WriteBytes(writer, "TextureAnimation", sop.TextureAnimation); + WriteBytes(writer, "ParticleSystem", sop.ParticleSystem); writer.WriteEndElement(); } @@ -1161,6 +1175,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); } + static void WriteBytes(XmlTextWriter writer, string name, byte[] data) + { + writer.WriteStartElement(name); + byte[] d; + if (data != null) + d = data; + else + d = Utils.EmptyBytes; + writer.WriteBase64(d, 0, d.Length); + writer.WriteEndElement(); // name + + } + static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary options) { if (tinv.Count > 0) // otherwise skip this -- cgit v1.1 From 3b2d9a99390e44d99bf00a6be685c08e307b9e42 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Oct 2010 14:37:03 -0700 Subject: Added code to quaternion deserialization to try to cope with an exception seen in Wright Plaza related to SitTargetOrientation. 17:23:05 - [SceneObjectSerializer]: exception while parsing SitTargetOrientation: System.Xml.XmlException: Expecting X tag from namespace , got w and instead Line 1, position 30064. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index b6aa31b..3a48299 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1438,10 +1438,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization Quaternion quat; reader.ReadStartElement(name); - quat.X = reader.ReadElementContentAsFloat("X", String.Empty); - quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty); - quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty); - quat.W = reader.ReadElementContentAsFloat("W", String.Empty); + if (reader.Name == "X") // assume X, Y, Z, W order + { + quat.X = reader.ReadElementContentAsFloat("X", String.Empty); + quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty); + quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty); + quat.W = reader.ReadElementContentAsFloat("W", String.Empty); + } + else // assume w, x, y, z + { + quat.W = reader.ReadElementContentAsFloat("w", String.Empty); + quat.X = reader.ReadElementContentAsFloat("x", String.Empty); + quat.Y = reader.ReadElementContentAsFloat("y", String.Empty); + quat.Z = reader.ReadElementContentAsFloat("z", String.Empty); + } + reader.ReadEndElement(); return quat; -- cgit v1.1 From 8acac3d07f63769051d5aad9a54953d033210f48 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Oct 2010 15:07:15 -0700 Subject: Another take related to the previous commit. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3a48299..58ec8a6 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1435,22 +1435,26 @@ namespace OpenSim.Region.Framework.Scenes.Serialization static Quaternion ReadQuaternion(XmlTextReader reader, string name) { - Quaternion quat; + Quaternion quat = new Quaternion(); reader.ReadStartElement(name); - if (reader.Name == "X") // assume X, Y, Z, W order - { - quat.X = reader.ReadElementContentAsFloat("X", String.Empty); - quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty); - quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty); - quat.W = reader.ReadElementContentAsFloat("W", String.Empty); - } - else // assume w, x, y, z + while (reader.NodeType != XmlNodeType.EndElement) { - quat.W = reader.ReadElementContentAsFloat("w", String.Empty); - quat.X = reader.ReadElementContentAsFloat("x", String.Empty); - quat.Y = reader.ReadElementContentAsFloat("y", String.Empty); - quat.Z = reader.ReadElementContentAsFloat("z", String.Empty); + switch (reader.Name.ToLower()) + { + case "x": + quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + break; + case "y": + quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + break; + case "z": + quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + break; + case "w": + quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + break; + } } reader.ReadEndElement(); -- cgit v1.1 From 8731c2be11085469c051dfea067b930520059a6a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Oct 2010 15:16:29 -0700 Subject: It looks like Vector3s also got written down in lower case at some point in time. Added code to account for that. 17:45:59 - [SceneObjectSerializer]: exception while parsing SitTargetPosition: System.Xml.XmlException: Expecting X tag from namespace , got x and instead Line 1, position 2838. --- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 58ec8a6..044b599 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1425,9 +1425,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization Vector3 vec; reader.ReadStartElement(name); - vec.X = reader.ReadElementContentAsFloat("X", String.Empty); - vec.Y = reader.ReadElementContentAsFloat("Y", String.Empty); - vec.Z = reader.ReadElementContentAsFloat("Z", String.Empty); + vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x + vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or Y + vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z reader.ReadEndElement(); return vec; -- cgit v1.1