From 54a3b8e079539d1d17b845be5c90702303452b0a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Oct 2010 08:16:41 -0700 Subject: New SOG/SOP parser using XmlTextReader + delegates dictionary. Active for load oar and load xml2, but not for packing objects on crossings/TPs yet. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 1353 ++++++++++++++++++++ .../Scenes/Serialization/SceneXmlLoader.cs | 35 +- 2 files changed, 1381 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index f5f6b90..2c6d999 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -26,6 +26,8 @@ */ using System; +using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Reflection; using System.Xml; @@ -294,5 +296,1356 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); } + + #region manual serialization + + private delegate void SOPXmlProcessor(SceneObjectPart sop, XmlTextReader reader); + private static Dictionary m_SOPXmlProcessors = new Dictionary(); + + private delegate void TaskInventoryXmlProcessor(TaskInventoryItem item, XmlTextReader reader); + private static Dictionary m_TaskInventoryXmlProcessors = new Dictionary(); + + private delegate void ShapeXmlProcessor(PrimitiveBaseShape shape, XmlTextReader reader); + private static Dictionary m_ShapeXmlProcessors = new Dictionary(); + + static SceneObjectSerializer() + { + #region SOPXmlProcessors initialization + m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop); + m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID); + m_SOPXmlProcessors.Add("FolderID", ProcessFolderID); + m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial); + m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory); + m_SOPXmlProcessors.Add("ObjectFlags", ProcessObjectFlags); + m_SOPXmlProcessors.Add("UUID", ProcessUUID); + m_SOPXmlProcessors.Add("LocalId", ProcessLocalId); + m_SOPXmlProcessors.Add("Name", ProcessName); + m_SOPXmlProcessors.Add("Material", ProcessMaterial); + m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches); + m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle); + m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin); + m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition); + m_SOPXmlProcessors.Add("OffsetPosition", ProcessOffsetPosition); + m_SOPXmlProcessors.Add("RotationOffset", ProcessRotationOffset); + m_SOPXmlProcessors.Add("Velocity", ProcessVelocity); + m_SOPXmlProcessors.Add("AngularVelocity", ProcessAngularVelocity); + m_SOPXmlProcessors.Add("Acceleration", ProcessAcceleration); + m_SOPXmlProcessors.Add("Description", ProcessDescription); + m_SOPXmlProcessors.Add("Color", ProcessColor); + m_SOPXmlProcessors.Add("Text", ProcessText); + m_SOPXmlProcessors.Add("SitName", ProcessSitName); + m_SOPXmlProcessors.Add("TouchName", ProcessTouchName); + m_SOPXmlProcessors.Add("LinkNum", ProcessLinkNum); + m_SOPXmlProcessors.Add("ClickAction", ProcessClickAction); + m_SOPXmlProcessors.Add("Shape", ProcessShape); + m_SOPXmlProcessors.Add("Scale", ProcessScale); + m_SOPXmlProcessors.Add("UpdateFlag", ProcessUpdateFlag); + m_SOPXmlProcessors.Add("SitTargetOrientation", ProcessSitTargetOrientation); + m_SOPXmlProcessors.Add("SitTargetPosition", ProcessSitTargetPosition); + m_SOPXmlProcessors.Add("SitTargetPositionLL", ProcessSitTargetPositionLL); + m_SOPXmlProcessors.Add("SitTargetOrientationLL", ProcessSitTargetOrientationLL); + m_SOPXmlProcessors.Add("ParentID", ProcessParentID); + m_SOPXmlProcessors.Add("CreationDate", ProcessCreationDate); + m_SOPXmlProcessors.Add("Category", ProcessCategory); + m_SOPXmlProcessors.Add("SalePrice", ProcessSalePrice); + m_SOPXmlProcessors.Add("ObjectSaleType", ProcessObjectSaleType); + m_SOPXmlProcessors.Add("OwnershipCost", ProcessOwnershipCost); + m_SOPXmlProcessors.Add("GroupID", ProcessGroupID); + m_SOPXmlProcessors.Add("OwnerID", ProcessOwnerID); + m_SOPXmlProcessors.Add("LastOwnerID", ProcessLastOwnerID); + m_SOPXmlProcessors.Add("BaseMask", ProcessBaseMask); + m_SOPXmlProcessors.Add("OwnerMask", ProcessOwnerMask); + m_SOPXmlProcessors.Add("GroupMask", ProcessGroupMask); + m_SOPXmlProcessors.Add("EveryoneMask", ProcessEveryoneMask); + m_SOPXmlProcessors.Add("NextOwnerMask", ProcessNextOwnerMask); + m_SOPXmlProcessors.Add("Flags", ProcessFlags); + m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); + m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); + #endregion + + #region TaskInventoryXmlProcessors initialization + m_TaskInventoryXmlProcessors.Add("AssetID", ProcessTIAssetID); + m_TaskInventoryXmlProcessors.Add("BasePermissions", ProcessTIBasePermissions); + m_TaskInventoryXmlProcessors.Add("CreationDate", ProcessTICreationDate); + m_TaskInventoryXmlProcessors.Add("CreatorID", ProcessTICreatorID); + m_TaskInventoryXmlProcessors.Add("Description", ProcessTIDescription); + m_TaskInventoryXmlProcessors.Add("EveryonePermissions", ProcessTIEveryonePermissions); + m_TaskInventoryXmlProcessors.Add("Flags", ProcessTIFlags); + m_TaskInventoryXmlProcessors.Add("GroupID", ProcessTIGroupID); + m_TaskInventoryXmlProcessors.Add("GroupPermissions", ProcessTIGroupPermissions); + m_TaskInventoryXmlProcessors.Add("InvType", ProcessTIInvType); + m_TaskInventoryXmlProcessors.Add("ItemID", ProcessTIItemID); + m_TaskInventoryXmlProcessors.Add("OldItemID", ProcessTIOldItemID); + m_TaskInventoryXmlProcessors.Add("LastOwnerID", ProcessTILastOwnerID); + m_TaskInventoryXmlProcessors.Add("Name", ProcessTIName); + m_TaskInventoryXmlProcessors.Add("NextPermissions", ProcessTINextPermissions); + m_TaskInventoryXmlProcessors.Add("OwnerID", ProcessTIOwnerID); + m_TaskInventoryXmlProcessors.Add("CurrentPermissions", ProcessTICurrentPermissions); + m_TaskInventoryXmlProcessors.Add("ParentID", ProcessTIParentID); + m_TaskInventoryXmlProcessors.Add("ParentPartID", ProcessTIParentPartID); + m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); + m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); + m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); + #endregion + + #region ShapeXmlProcessors initialization + m_ShapeXmlProcessors.Add("ProfileCurve", ProcessShpProfileCurve); + m_ShapeXmlProcessors.Add("TextureEntry", ProcessShpTextureEntry); + m_ShapeXmlProcessors.Add("ExtraParams", ProcessShpExtraParams); + m_ShapeXmlProcessors.Add("PathBegin", ProcessShpPathBegin); + m_ShapeXmlProcessors.Add("PathCurve", ProcessShpPathCurve); + m_ShapeXmlProcessors.Add("PathEnd", ProcessShpPathEnd); + m_ShapeXmlProcessors.Add("PathRadiusOffset", ProcessShpPathRadiusOffset); + m_ShapeXmlProcessors.Add("PathRevolutions", ProcessShpPathRevolutions); + m_ShapeXmlProcessors.Add("PathScaleX", ProcessShpPathScaleX); + m_ShapeXmlProcessors.Add("PathScaleY", ProcessShpPathScaleY); + m_ShapeXmlProcessors.Add("PathShearX", ProcessShpPathShearX); + m_ShapeXmlProcessors.Add("PathShearY", ProcessShpPathShearY); + m_ShapeXmlProcessors.Add("PathSkew", ProcessShpPathSkew); + m_ShapeXmlProcessors.Add("PathTaperX", ProcessShpPathTaperX); + m_ShapeXmlProcessors.Add("PathTaperY", ProcessShpPathTaperY); + m_ShapeXmlProcessors.Add("PathTwist", ProcessShpPathTwist); + m_ShapeXmlProcessors.Add("PathTwistBegin", ProcessShpPathTwistBegin); + m_ShapeXmlProcessors.Add("PCode", ProcessShpPCode); + m_ShapeXmlProcessors.Add("ProfileBegin", ProcessShpProfileBegin); + m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd); + m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow); + m_ShapeXmlProcessors.Add("Scale", ProcessShpScale); + m_ShapeXmlProcessors.Add("State", ProcessShpState); + m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape); + m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape); + m_ShapeXmlProcessors.Add("SculptTexture", ProcessShpSculptTexture); + m_ShapeXmlProcessors.Add("SculptType", ProcessShpSculptType); + m_ShapeXmlProcessors.Add("SculptData", ProcessShpSculptData); + m_ShapeXmlProcessors.Add("FlexiSoftness", ProcessShpFlexiSoftness); + m_ShapeXmlProcessors.Add("FlexiTension", ProcessShpFlexiTension); + m_ShapeXmlProcessors.Add("FlexiDrag", ProcessShpFlexiDrag); + m_ShapeXmlProcessors.Add("FlexiGravity", ProcessShpFlexiGravity); + m_ShapeXmlProcessors.Add("FlexiWind", ProcessShpFlexiWind); + m_ShapeXmlProcessors.Add("FlexiForceX", ProcessShpFlexiForceX); + m_ShapeXmlProcessors.Add("FlexiForceY", ProcessShpFlexiForceY); + m_ShapeXmlProcessors.Add("FlexiForceZ", ProcessShpFlexiForceZ); + m_ShapeXmlProcessors.Add("LightColorR", ProcessShpLightColorR); + m_ShapeXmlProcessors.Add("LightColorG", ProcessShpLightColorG); + m_ShapeXmlProcessors.Add("LightColorB", ProcessShpLightColorB); + m_ShapeXmlProcessors.Add("LightColorA", ProcessShpLightColorA); + m_ShapeXmlProcessors.Add("LightRadius", ProcessShpLightRadius); + m_ShapeXmlProcessors.Add("LightCutoff", ProcessShpLightCutoff); + m_ShapeXmlProcessors.Add("LightFalloff", ProcessShpLightFalloff); + m_ShapeXmlProcessors.Add("LightIntensity", ProcessShpLightIntensity); + m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry); + m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry); + m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry); + #endregion + } + + #region SOPXmlProcessors + private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader) + { + obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); + } + + private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) + { + obj.CreatorID = ReadUUID(reader, "CreatorID"); + } + + private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) + { + obj.FolderID = ReadUUID(reader, "FolderID"); + } + + private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) + { + obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty); + } + + private static void ProcessTaskInventory(SceneObjectPart obj, XmlTextReader reader) + { + obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory"); + } + + private static void ProcessObjectFlags(SceneObjectPart obj, XmlTextReader reader) + { + obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); + } + + private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) + { + obj.UUID = ReadUUID(reader, "UUID"); + } + + private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader) + { + obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty); + } + + private static void ProcessName(SceneObjectPart obj, XmlTextReader reader) + { + obj.Name = reader.ReadElementString("Name"); + } + + private static void ProcessMaterial(SceneObjectPart obj, XmlTextReader reader) + { + obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty); + } + + private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader) + { + obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); + } + + private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader) + { + obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); + } + + private static void ProcessScriptAccessPin(SceneObjectPart obj, XmlTextReader reader) + { + obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty); + } + + private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) + { + obj.GroupPosition = ReadVector(reader, "GroupPosition"); + } + + private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) + { + obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ; + } + + private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) + { + obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); + } + + private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) + { + obj.Velocity = ReadVector(reader, "Velocity"); + } + + private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) + { + obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); + } + + private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) + { + obj.Acceleration = ReadVector(reader, "Acceleration"); + } + + private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) + { + obj.Description = reader.ReadElementString("Description"); + } + + private static void ProcessColor(SceneObjectPart obj, XmlTextReader reader) + { + reader.ReadStartElement("Color"); + if (reader.Name == "R") + { + float r = reader.ReadElementContentAsFloat("R", String.Empty); + float g = reader.ReadElementContentAsFloat("G", String.Empty); + float b = reader.ReadElementContentAsFloat("B", String.Empty); + float a = reader.ReadElementContentAsFloat("A", String.Empty); + obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b); + reader.ReadEndElement(); + } + } + + private static void ProcessText(SceneObjectPart obj, XmlTextReader reader) + { + obj.Text = reader.ReadElementString("Text", String.Empty); + } + + private static void ProcessSitName(SceneObjectPart obj, XmlTextReader reader) + { + obj.SitName = reader.ReadElementString("SitName", String.Empty); + } + + private static void ProcessTouchName(SceneObjectPart obj, XmlTextReader reader) + { + obj.TouchName = reader.ReadElementString("TouchName", String.Empty); + } + + private static void ProcessLinkNum(SceneObjectPart obj, XmlTextReader reader) + { + obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty); + } + + private static void ProcessClickAction(SceneObjectPart obj, XmlTextReader reader) + { + obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); + } + + private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) + { + obj.Shape = ReadShape(reader, "Shape"); + } + + private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) + { + obj.Scale = ReadVector(reader, "Scale"); + } + + private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) + { + obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); + } + + private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) + { + obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); + } + + private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) + { + obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); + } + + private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) + { + obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); + } + + private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) + { + obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); + } + + private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) + { + string str = reader.ReadElementContentAsString("ParentID", String.Empty); + obj.ParentID = Convert.ToUInt32(str); + } + + private static void ProcessCreationDate(SceneObjectPart obj, XmlTextReader reader) + { + obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); + } + + private static void ProcessCategory(SceneObjectPart obj, XmlTextReader reader) + { + obj.Category = (uint)reader.ReadElementContentAsInt("Category", String.Empty); + } + + private static void ProcessSalePrice(SceneObjectPart obj, XmlTextReader reader) + { + obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); + } + + private static void ProcessObjectSaleType(SceneObjectPart obj, XmlTextReader reader) + { + obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty); + } + + private static void ProcessOwnershipCost(SceneObjectPart obj, XmlTextReader reader) + { + obj.OwnershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty); + } + + private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) + { + obj.GroupID = ReadUUID(reader, "GroupID"); + } + + private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) + { + obj.OwnerID = ReadUUID(reader, "OwnerID"); + } + + private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) + { + obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); + } + + private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) + { + obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty); + } + + private static void ProcessOwnerMask(SceneObjectPart obj, XmlTextReader reader) + { + obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty); + } + + private static void ProcessGroupMask(SceneObjectPart obj, XmlTextReader reader) + { + obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty); + } + + private static void ProcessEveryoneMask(SceneObjectPart obj, XmlTextReader reader) + { + obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty); + } + + private static void ProcessNextOwnerMask(SceneObjectPart obj, XmlTextReader reader) + { + obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty); + } + + private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader) + { + string value = reader.ReadElementContentAsString("Flags", String.Empty); + // !!!!! to deal with flags without commas + if (value.Contains(" ") && !value.Contains(",")) + value = value.Replace(" ", ", "); + obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value); + } + + private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader) + { + obj.CollisionSound = ReadUUID(reader, "CollisionSound"); + } + + private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) + { + obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); + } + #endregion + + #region TaskInventoryXmlProcessors + private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) + { + item.AssetID = ReadUUID(reader, "AssetID"); + } + + private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) + { + item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); + } + + private static void ProcessTICreationDate(TaskInventoryItem item, XmlTextReader reader) + { + item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty); + } + + private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) + { + item.CreatorID = ReadUUID(reader, "CreatorID"); + } + + private static void ProcessTIDescription(TaskInventoryItem item, XmlTextReader reader) + { + item.Description = reader.ReadElementContentAsString("Description", String.Empty); + } + + private static void ProcessTIEveryonePermissions(TaskInventoryItem item, XmlTextReader reader) + { + item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty); + } + + private static void ProcessTIFlags(TaskInventoryItem item, XmlTextReader reader) + { + item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); + } + + private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) + { + item.GroupID = ReadUUID(reader, "GroupID"); + } + + private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) + { + item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty); + } + + private static void ProcessTIInvType(TaskInventoryItem item, XmlTextReader reader) + { + item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); + } + + private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) + { + item.ItemID = ReadUUID(reader, "ItemID"); + } + + private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) + { + item.OldItemID = ReadUUID(reader, "OldItemID"); + } + + private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) + { + item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); + } + + private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) + { + item.Name = reader.ReadElementContentAsString("Name", String.Empty); + } + + private static void ProcessTINextPermissions(TaskInventoryItem item, XmlTextReader reader) + { + item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); + } + + private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) + { + item.OwnerID = ReadUUID(reader, "OwnerID"); + } + + private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) + { + item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); + } + + private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) + { + item.ParentID = ReadUUID(reader, "ParentID"); + } + + private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) + { + item.ParentPartID = ReadUUID(reader, "ParentPartID"); + } + + private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) + { + item.PermsGranter = ReadUUID(reader, "PermsGranter"); + } + + private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) + { + item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); + } + + private static void ProcessTIType(TaskInventoryItem item, XmlTextReader reader) + { + item.Type = reader.ReadElementContentAsInt("Type", String.Empty); + } + + #endregion + + #region ShapeXmlProcessors + private static void ProcessShpProfileCurve(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); + } + + private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlTextReader reader) + { + byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry")); + shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); + } + + private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString("ExtraParams")); + } + + private static void ProcessShpPathBegin(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty); + } + + private static void ProcessShpPathCurve(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty); + } + + private static void ProcessShpPathEnd(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty); + } + + private static void ProcessShpPathRadiusOffset(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty); + } + + private static void ProcessShpPathRevolutions(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty); + } + + private static void ProcessShpPathScaleX(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty); + } + + private static void ProcessShpPathScaleY(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty); + } + + private static void ProcessShpPathShearX(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty); + } + + private static void ProcessShpPathShearY(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty); + } + + private static void ProcessShpPathSkew(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty); + } + + private static void ProcessShpPathTaperX(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty); + } + + private static void ProcessShpPathTaperY(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty); + } + + private static void ProcessShpPathTwist(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty); + } + + private static void ProcessShpPathTwistBegin(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty); + } + + private static void ProcessShpPCode(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty); + } + + private static void ProcessShpProfileBegin(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty); + } + + private static void ProcessShpProfileEnd(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty); + } + + private static void ProcessShpProfileHollow(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty); + } + + private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.Scale = ReadVector(reader, "Scale"); + } + + private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); + } + + private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader) + { + string value = reader.ReadElementContentAsString("ProfileShape", String.Empty); + // !!!!! to deal with flags without commas + if (value.Contains(" ") && !value.Contains(",")) + value = value.Replace(" ", ", "); + shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value); + } + + private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader) + { + string value = reader.ReadElementContentAsString("HollowShape", String.Empty); + // !!!!! to deal with flags without commas + if (value.Contains(" ") && !value.Contains(",")) + value = value.Replace(" ", ", "); + shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value); + } + + private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.SculptTexture = ReadUUID(reader, "SculptTexture"); + } + + private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.SculptType = (byte)reader.ReadElementContentAsInt("SculptType", String.Empty); + } + + private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData")); + } + + private static void ProcessShpFlexiSoftness(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty); + } + + private static void ProcessShpFlexiTension(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty); + } + + private static void ProcessShpFlexiDrag(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty); + } + + private static void ProcessShpFlexiGravity(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty); + } + + private static void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty); + } + + private static void ProcessShpFlexiForceX(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty); + } + + private static void ProcessShpFlexiForceY(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty); + } + + private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty); + } + + private static void ProcessShpLightColorR(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty); + } + + private static void ProcessShpLightColorG(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty); + } + + private static void ProcessShpLightColorB(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty); + } + + private static void ProcessShpLightColorA(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty); + } + + private static void ProcessShpLightRadius(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty); + } + + private static void ProcessShpLightCutoff(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty); + } + + private static void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty); + } + + private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty); + } + + private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); + } + + private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); + } + + private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); + } + + #endregion + + ////////// Write ///////// + + public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog) + { + writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); + SOPToXml2(writer, sog.RootPart, null); + writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); + + sog.ForEachPart(delegate(SceneObjectPart sop) + { + SOPToXml2(writer, sop, sog.RootPart); + }); + + writer.WriteEndElement(); + writer.WriteEndElement(); + } + + static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent) + { + writer.WriteStartElement("SceneObjectPart"); + writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); + + WriteUUID(writer, "CreatorID", sop.CreatorID); + WriteUUID(writer, "FolderID", sop.FolderID); + writer.WriteElementString("InventorySerial", (sop.Inventory != null) ? sop.InventorySerial.ToString() : "0"); + + // FIXME: Task inventory + writer.WriteStartElement("TaskInventory"); writer.WriteEndElement(); + + writer.WriteElementString("ObjectFlags", ((int)sop.Flags).ToString()); + + WriteUUID(writer, "UUID", sop.UUID); + writer.WriteElementString("LocalId", sop.LocalId.ToString()); + writer.WriteElementString("Name", sop.Name); + writer.WriteElementString("Material", ((int)sop.Material).ToString()); + writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString()); + writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString()); + + WriteVector(writer, "GroupPosition", sop.GroupPosition); + WriteVector(writer, "OffsetPosition", sop.OffsetPosition); + + WriteQuaternion(writer, "RotationOffset", sop.RotationOffset); + WriteVector(writer, "Velocity", sop.Velocity); + WriteVector(writer, "RotationalVelocity", Vector3.Zero); + WriteVector(writer, "AngularVelocity", sop.AngularVelocity); + WriteVector(writer, "Acceleration", sop.Acceleration); + writer.WriteElementString("Description", sop.Description); + writer.WriteStartElement("Color"); + writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); + writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); + writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); + writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + writer.WriteElementString("Text", sop.Text); + writer.WriteElementString("SitName", sop.SitName); + writer.WriteElementString("TouchName", sop.TouchName); + + writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); + writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); + writer.WriteStartElement("Shape"); + + writer.WriteElementString("ProfileCurve", sop.Shape.ProfileCurve.ToString()); + + writer.WriteStartElement("TextureEntry"); + byte[] te; + if (sop.Shape.TextureEntry != null) + te = sop.Shape.TextureEntry; + else + te = Utils.EmptyBytes; + writer.WriteBase64(te, 0, te.Length); + writer.WriteEndElement(); // TextureEntry + + writer.WriteStartElement("ExtraParams"); + byte[] ep; + if (sop.Shape.ExtraParams != null) + ep = sop.Shape.ExtraParams; + else + ep = Utils.EmptyBytes; + writer.WriteBase64(ep, 0, ep.Length); + writer.WriteEndElement(); // ExtraParams + + writer.WriteElementString("PathBegin", Primitive.PackBeginCut(sop.Shape.PathBegin).ToString()); + writer.WriteElementString("PathCurve", sop.Shape.PathCurve.ToString()); + writer.WriteElementString("PathEnd", Primitive.PackEndCut(sop.Shape.PathEnd).ToString()); + writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(sop.Shape.PathRadiusOffset).ToString()); + writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(sop.Shape.PathRevolutions).ToString()); + writer.WriteElementString("PathScaleX", Primitive.PackPathScale(sop.Shape.PathScaleX).ToString()); + writer.WriteElementString("PathScaleY", Primitive.PackPathScale(sop.Shape.PathScaleY).ToString()); + writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(sop.Shape.PathShearX)).ToString()); + writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(sop.Shape.PathShearY)).ToString()); + writer.WriteElementString("PathSkew", Primitive.PackPathTwist(sop.Shape.PathSkew).ToString()); + writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(sop.Shape.PathTaperX).ToString()); + writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(sop.Shape.PathTaperY).ToString()); + writer.WriteElementString("PathTwist", Primitive.PackPathTwist(sop.Shape.PathTwist).ToString()); + writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(sop.Shape.PathTwistBegin).ToString()); + writer.WriteElementString("PCode", sop.Shape.PCode.ToString()); + writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(sop.Shape.ProfileBegin).ToString()); + writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(sop.Shape.ProfileEnd).ToString()); + writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(sop.Shape.ProfileHollow).ToString()); + WriteVector(writer, "Scale", sop.Scale); + writer.WriteElementString("State", sop.Shape.State.ToString()); + + writer.WriteElementString("ProfileShape", sop.Shape.ProfileShape.ToString()); + writer.WriteElementString("HollowShape", sop.Shape.HollowShape.ToString()); + + writer.WriteElementString("SculptTexture", sop.Shape.SculptTexture.ToString()); + writer.WriteElementString("SculptType", sop.Shape.SculptType.ToString()); + writer.WriteStartElement("SculptData"); + byte[] sd; + if (sop.Shape.SculptData != null) + sd = sop.Shape.ExtraParams; + else + sd = Utils.EmptyBytes; + writer.WriteBase64(sd, 0, sd.Length); + writer.WriteEndElement(); // SculptData + + writer.WriteElementString("FlexiSoftness", sop.Shape.FlexiSoftness.ToString()); + writer.WriteElementString("FlexiTension", sop.Shape.FlexiTension.ToString()); + writer.WriteElementString("FlexiDrag", sop.Shape.FlexiDrag.ToString()); + writer.WriteElementString("FlexiGravity", sop.Shape.FlexiGravity.ToString()); + writer.WriteElementString("FlexiWind", sop.Shape.FlexiWind.ToString()); + writer.WriteElementString("FlexiForceX", sop.Shape.FlexiForceX.ToString()); + writer.WriteElementString("FlexiForceY", sop.Shape.FlexiForceY.ToString()); + writer.WriteElementString("FlexiForceZ", sop.Shape.FlexiForceZ.ToString()); + + writer.WriteElementString("LightColorR", sop.Shape.LightColorR.ToString()); + writer.WriteElementString("LightColorG", sop.Shape.LightColorG.ToString()); + writer.WriteElementString("LightColorB", sop.Shape.LightColorB.ToString()); + writer.WriteElementString("LightColorA", sop.Shape.LightColorA.ToString()); + writer.WriteElementString("LightRadius", sop.Shape.LightRadius.ToString()); + writer.WriteElementString("LightCutoff", sop.Shape.LightCutoff.ToString()); + writer.WriteElementString("LightFalloff", sop.Shape.LightFalloff.ToString()); + writer.WriteElementString("LightIntensity", sop.Shape.LightIntensity.ToString()); + + writer.WriteElementString("FlexyEntry", sop.Shape.FlexiEntry.ToString()); + writer.WriteElementString("LightEntry", sop.Shape.LightEntry.ToString()); + writer.WriteElementString("SculptEntry", sop.Shape.SculptEntry.ToString()); + + writer.WriteEndElement(); // Shape + + WriteVector(writer, "Scale", sop.Scale); + writer.WriteElementString("UpdateFlag", "0"); + WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation); + WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition); + WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL); + WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL); + writer.WriteElementString("ParentID", sop.ParentID.ToString()); + writer.WriteElementString("CreationDate", sop.CreationDate.ToString()); + writer.WriteElementString("Category", "0"); + writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); + writer.WriteElementString("ObjectSaleType", ((int)sop.ObjectSaleType).ToString()); + writer.WriteElementString("OwnershipCost", "0"); + WriteUUID(writer, "GroupID", sop.GroupID); + WriteUUID(writer, "OwnerID", sop.OwnerID); + WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); + writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); + writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); + writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); + writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); + writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); + writer.WriteElementString("Flags", sop.Flags.ToString()); + WriteUUID(writer, "CollisionSound", sop.CollisionSound); + writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); + + writer.WriteEndElement(); + } + + static void WriteUUID(XmlTextWriter writer, string name, UUID id) + { + writer.WriteStartElement(name); + writer.WriteElementString("UUID", id.ToString()); + writer.WriteEndElement(); + } + + static void WriteVector(XmlTextWriter writer, string name, Vector3 vec) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); + writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + + //////// Read ///////// + public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) + { + reader.Read(); + reader.ReadStartElement("SceneObjectGroup"); + SceneObjectPart root = Xml2ToSOP(reader); + if (root != null) + sog.SetRootPart(root); + else + { + return false; + } + + if (sog.UUID == UUID.Zero) + sog.UUID = sog.RootPart.UUID; + + reader.Read(); // OtherParts + + while (!reader.EOF) + { + switch (reader.NodeType) + { + case XmlNodeType.Element: + if (reader.Name == "SceneObjectPart") + { + SceneObjectPart child = Xml2ToSOP(reader); + if (child != null) + sog.AddPart(child); + } + else + { + //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug); + reader.Read(); + } + break; + case XmlNodeType.EndElement: + default: + reader.Read(); + break; + } + + } + return true; + } + + public static SceneObjectPart Xml2ToSOPPull(XmlTextReader reader) + { + SceneObjectPart obj = new SceneObjectPart(); + + reader.ReadStartElement("SceneObjectPart"); + + if (reader.Name == "AllowedDrop") + obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); + else + obj.AllowedDrop = true; + + obj.CreatorID = ReadUUID(reader, "CreatorID"); + obj.FolderID = ReadUUID(reader, "FolderID"); + obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty); + + #region Task Inventory + + obj.TaskInventory = new TaskInventoryDictionary(); + //List invItems = new List(); + + reader.ReadStartElement("TaskInventory", String.Empty); + while (reader.Name == "TaskInventoryItem") + { + TaskInventoryItem item = new TaskInventoryItem(); + reader.ReadStartElement("TaskInventoryItem", String.Empty); + + item.AssetID = ReadUUID(reader, "AssetID"); + item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); + item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty); + item.CreatorID = ReadUUID(reader, "CreatorID"); + item.Description = reader.ReadElementContentAsString("Description", String.Empty); + item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty); + item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); + item.GroupID = ReadUUID(reader, "GroupID"); + item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty); + item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); + item.ItemID = ReadUUID(reader, "ItemID"); + UUID oldItemID = ReadUUID(reader, "OldItemID"); // TODO: Is this useful? + item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); + item.Name = reader.ReadElementContentAsString("Name", String.Empty); + item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); + item.OwnerID = ReadUUID(reader, "OwnerID"); + item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); + UUID parentID = ReadUUID(reader, "ParentID"); + UUID parentPartID = ReadUUID(reader, "ParentPartID"); + item.PermsGranter = ReadUUID(reader, "PermsGranter"); + item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); + item.Type = reader.ReadElementContentAsInt("Type", String.Empty); + + reader.ReadEndElement(); + obj.TaskInventory.Add(item.ItemID, item); + } + if (reader.NodeType == XmlNodeType.EndElement) + reader.ReadEndElement(); + + #endregion Task Inventory + + obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); + + obj.UUID = ReadUUID(reader, "UUID"); + obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty); + obj.Name = reader.ReadElementString("Name"); + obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty); + + if (reader.Name == "PassTouches") + obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); + else + obj.PassTouches = false; + + obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); + obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty); + + if (reader.Name == "PlaySoundSlavePrims") + reader.ReadInnerXml(); + if (reader.Name == "LoopSoundSlavePrims") + reader.ReadInnerXml(); + + Vector3 groupPosition = ReadVector(reader, "GroupPosition"); + Vector3 offsetPosition = ReadVector(reader, "OffsetPosition"); + obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); + obj.Velocity = ReadVector(reader, "Velocity"); + if (reader.Name == "RotationalVelocity") + ReadVector(reader, "RotationalVelocity"); + obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); + obj.Acceleration = ReadVector(reader, "Acceleration"); + obj.Description = reader.ReadElementString("Description"); + reader.ReadStartElement("Color"); + if (reader.Name == "R") + { + obj.Color = Color.FromArgb((int)reader.ReadElementContentAsFloat("A", String.Empty), + (int)reader.ReadElementContentAsFloat("R", String.Empty), + (int)reader.ReadElementContentAsFloat("G", String.Empty), + (int)reader.ReadElementContentAsFloat("B", String.Empty)); + reader.ReadEndElement(); + } + obj.Text = reader.ReadElementString("Text", String.Empty); + obj.SitName = reader.ReadElementString("SitName", String.Empty); + obj.TouchName = reader.ReadElementString("TouchName", String.Empty); + + obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty); + obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); + + reader.ReadStartElement("Shape"); + obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); + + byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry")); + obj.Shape.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); + + reader.ReadInnerXml(); // ExtraParams + + obj.Shape.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty); + obj.Shape.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty); + obj.Shape.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty); + obj.Shape.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty); + obj.Shape.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty); + obj.Shape.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty); + obj.Shape.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty); + obj.Shape.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty); + obj.Shape.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty); + obj.Shape.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty); + obj.Shape.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty); + obj.Shape.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty); + obj.Shape.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty); + obj.Shape.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty); + obj.Shape.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty); + obj.Shape.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty); + obj.Shape.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty); + obj.Shape.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty); + obj.Scale = ReadVector(reader, "Scale"); + obj.Shape.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); + + obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); + obj.Shape.ProfileShape = (ProfileShape)reader.ReadElementContentAsInt("ProfileShape", String.Empty); + obj.Shape.HollowShape = (HollowShape)reader.ReadElementContentAsInt("HollowShape", String.Empty); + + UUID sculptTexture = ReadUUID(reader, "SculptTexture"); + SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty); + if (sculptTexture != UUID.Zero) + { + obj.Shape.SculptTexture = sculptTexture; + obj.Shape.SculptType = (byte)sculptType; + } + + reader.ReadInnerXml(); // SculptData + + obj.Shape.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty); + obj.Shape.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty); + obj.Shape.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty); + obj.Shape.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty); + obj.Shape.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty); + obj.Shape.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty); + obj.Shape.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty); + obj.Shape.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty); + + obj.Shape.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty); + obj.Shape.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty); + obj.Shape.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty); + obj.Shape.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty); + obj.Shape.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty); + obj.Shape.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty); + obj.Shape.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty); + obj.Shape.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty); + + bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); + bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); + reader.ReadInnerXml(); // SculptEntry + + reader.ReadEndElement(); + + obj.Scale = ReadVector(reader, "Scale"); // Yes, again + obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); // UpdateFlag + + obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); + obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); + obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); + obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); + obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty); + obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); + int category = reader.ReadElementContentAsInt("Category", String.Empty); + obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); + obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty); + int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty); + obj.GroupID = ReadUUID(reader, "GroupID"); + obj.OwnerID = ReadUUID(reader, "OwnerID"); + obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); + obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty); + obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty); + obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty); + obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty); + obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty); + + obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("Flags", String.Empty); + + obj.CollisionSound = ReadUUID(reader, "CollisionSound"); + obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); + + reader.ReadEndElement(); + + obj.GroupPosition = groupPosition; + obj.OffsetPosition = offsetPosition; + + return obj; + } + + public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) + { + SceneObjectPart obj = new SceneObjectPart(); + + reader.ReadStartElement("SceneObjectPart"); + + string nodeName = string.Empty; + while (reader.NodeType != XmlNodeType.EndElement) + { + nodeName = reader.Name; + SOPXmlProcessor p = null; + if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p)) + { + try + { + p(obj, reader); + } + catch (Exception e) + { + m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0} in {1}-{2}: {3}", nodeName, obj.Name, obj.UUID, e); + } + } + else + { + m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); + reader.ReadOuterXml(); // ignore + } + + } + + reader.ReadEndElement(); // SceneObjectPart + + //m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID); + return obj; + } + + static UUID ReadUUID(XmlTextReader reader, string name) + { + UUID id; + string idStr; + + reader.ReadStartElement(name); + + if (reader.Name == "Guid") + idStr = reader.ReadElementString("Guid"); + else // UUID + idStr = reader.ReadElementString("UUID"); + + UUID.TryParse(idStr, out id); + reader.ReadEndElement(); + + return id; + } + + static Vector3 ReadVector(XmlTextReader reader, string name) + { + 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); + reader.ReadEndElement(); + + return vec; + } + + static Quaternion ReadQuaternion(XmlTextReader reader, string name) + { + 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); + reader.ReadEndElement(); + + return quat; + } + + static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) + { + TaskInventoryDictionary tinv = new TaskInventoryDictionary(); + + reader.ReadStartElement(name, String.Empty); + + while (reader.Name == "TaskInventoryItem") + { + reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory + + TaskInventoryItem item = new TaskInventoryItem(); + while (reader.NodeType != XmlNodeType.EndElement) + { + TaskInventoryXmlProcessor p = null; + if (m_TaskInventoryXmlProcessors.TryGetValue(reader.Name, out p)) + p(item, reader); + else + { + m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value); + reader.ReadOuterXml(); + } + } + reader.ReadEndElement(); // TaskInventoryItem + tinv.Add(item.ItemID, item); + + } + + if (reader.NodeType == XmlNodeType.EndElement) + reader.ReadEndElement(); // TaskInventory + + return tinv; + } + + static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name) + { + PrimitiveBaseShape shape = new PrimitiveBaseShape(); + + reader.ReadStartElement(name, String.Empty); // Shape + + while (reader.NodeType != XmlNodeType.EndElement) + { + ShapeXmlProcessor p = null; + if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p)) + p(shape, reader); + else + { + m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name); + reader.ReadOuterXml(); + } + } + + reader.ReadEndElement(); // Shape + + return shape; + } + + #endregion } } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index 5494549..bb67ca0 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -124,14 +124,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization foreach (XmlNode aPrimNode in rootNode.ChildNodes) { // There is only ever one prim. This oddity should be removeable post 0.5.9 - return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); + //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); + using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml))) + { + SceneObjectGroup obj = new SceneObjectGroup(); + if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) + return obj; + + return null; + } } return null; } else { - return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); + //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); + using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml))) + { + SceneObjectGroup obj = new SceneObjectGroup(); + if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) + return obj; + + return null; + } } } @@ -193,12 +209,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization /// The scene object created. null if the scene object already existed protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) { - SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); + //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); + using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData))) + { + SceneObjectGroup obj = new SceneObjectGroup(); + SceneObjectSerializer.Xml2ToSOG(reader, obj); - if (scene.AddRestoredSceneObject(obj, true, false)) - return obj; - else - return null; + if (scene.AddRestoredSceneObject(obj, true, false)) + return obj; + else + return null; + } } public static void SavePrimsToXml2(Scene scene, string fileName) -- cgit v1.1 From d890390ecf693acf85e8115b859ca852824085d9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Oct 2010 10:38:34 -0700 Subject: Comment a debug message so that it doesn't spew the console upon encountering unknown xml elements. --- OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2c6d999..3fd61da 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1533,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } else { - m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); + //m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); reader.ReadOuterXml(); // ignore } -- cgit v1.1 From 45e0cdfcada82e0771e559614d798438d87b6ad3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Oct 2010 15:44:25 -0700 Subject: Added SOP.MediaUrl and Shape.Media to the deserialization --- .../Scenes/Serialization/SceneObjectSerializer.cs | 218 ++------------------- 1 file changed, 14 insertions(+), 204 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3fd61da..efd5a8e 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -361,6 +361,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Flags", ProcessFlags); m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); + m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); #endregion #region TaskInventoryXmlProcessors initialization @@ -436,6 +437,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry); m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry); m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry); + m_ShapeXmlProcessors.Add("Media", ProcessShpMedia); #endregion } @@ -703,6 +705,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); } + + private static void ProcessMediaUrl(SceneObjectPart obj, XmlTextReader reader) + { + obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty); + } #endregion #region TaskInventoryXmlProcessors @@ -1063,6 +1070,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); } + private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader) + { + string value = reader.ReadElementContentAsString("Media", String.Empty); + shp.Media = PrimitiveBaseShape.MediaList.FromXml(value); + } + + #endregion ////////// Write ///////// @@ -1305,210 +1319,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization return true; } - public static SceneObjectPart Xml2ToSOPPull(XmlTextReader reader) - { - SceneObjectPart obj = new SceneObjectPart(); - - reader.ReadStartElement("SceneObjectPart"); - - if (reader.Name == "AllowedDrop") - obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); - else - obj.AllowedDrop = true; - - obj.CreatorID = ReadUUID(reader, "CreatorID"); - obj.FolderID = ReadUUID(reader, "FolderID"); - obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty); - - #region Task Inventory - - obj.TaskInventory = new TaskInventoryDictionary(); - //List invItems = new List(); - - reader.ReadStartElement("TaskInventory", String.Empty); - while (reader.Name == "TaskInventoryItem") - { - TaskInventoryItem item = new TaskInventoryItem(); - reader.ReadStartElement("TaskInventoryItem", String.Empty); - - item.AssetID = ReadUUID(reader, "AssetID"); - item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); - item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty); - item.CreatorID = ReadUUID(reader, "CreatorID"); - item.Description = reader.ReadElementContentAsString("Description", String.Empty); - item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty); - item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); - item.GroupID = ReadUUID(reader, "GroupID"); - item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty); - item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); - item.ItemID = ReadUUID(reader, "ItemID"); - UUID oldItemID = ReadUUID(reader, "OldItemID"); // TODO: Is this useful? - item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); - item.Name = reader.ReadElementContentAsString("Name", String.Empty); - item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); - item.OwnerID = ReadUUID(reader, "OwnerID"); - item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); - UUID parentID = ReadUUID(reader, "ParentID"); - UUID parentPartID = ReadUUID(reader, "ParentPartID"); - item.PermsGranter = ReadUUID(reader, "PermsGranter"); - item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); - item.Type = reader.ReadElementContentAsInt("Type", String.Empty); - - reader.ReadEndElement(); - obj.TaskInventory.Add(item.ItemID, item); - } - if (reader.NodeType == XmlNodeType.EndElement) - reader.ReadEndElement(); - - #endregion Task Inventory - - obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); - - obj.UUID = ReadUUID(reader, "UUID"); - obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty); - obj.Name = reader.ReadElementString("Name"); - obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty); - - if (reader.Name == "PassTouches") - obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); - else - obj.PassTouches = false; - - obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); - obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty); - - if (reader.Name == "PlaySoundSlavePrims") - reader.ReadInnerXml(); - if (reader.Name == "LoopSoundSlavePrims") - reader.ReadInnerXml(); - - Vector3 groupPosition = ReadVector(reader, "GroupPosition"); - Vector3 offsetPosition = ReadVector(reader, "OffsetPosition"); - obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); - obj.Velocity = ReadVector(reader, "Velocity"); - if (reader.Name == "RotationalVelocity") - ReadVector(reader, "RotationalVelocity"); - obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); - obj.Acceleration = ReadVector(reader, "Acceleration"); - obj.Description = reader.ReadElementString("Description"); - reader.ReadStartElement("Color"); - if (reader.Name == "R") - { - obj.Color = Color.FromArgb((int)reader.ReadElementContentAsFloat("A", String.Empty), - (int)reader.ReadElementContentAsFloat("R", String.Empty), - (int)reader.ReadElementContentAsFloat("G", String.Empty), - (int)reader.ReadElementContentAsFloat("B", String.Empty)); - reader.ReadEndElement(); - } - obj.Text = reader.ReadElementString("Text", String.Empty); - obj.SitName = reader.ReadElementString("SitName", String.Empty); - obj.TouchName = reader.ReadElementString("TouchName", String.Empty); - - obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty); - obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); - - reader.ReadStartElement("Shape"); - obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); - - byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry")); - obj.Shape.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); - - reader.ReadInnerXml(); // ExtraParams - - obj.Shape.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty); - obj.Shape.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty); - obj.Shape.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty); - obj.Shape.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty); - obj.Shape.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty); - obj.Shape.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty); - obj.Shape.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty); - obj.Shape.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty); - obj.Shape.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty); - obj.Shape.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty); - obj.Shape.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty); - obj.Shape.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty); - obj.Shape.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty); - obj.Shape.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty); - obj.Shape.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty); - obj.Shape.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty); - obj.Shape.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty); - obj.Shape.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty); - obj.Scale = ReadVector(reader, "Scale"); - obj.Shape.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); - - obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); - obj.Shape.ProfileShape = (ProfileShape)reader.ReadElementContentAsInt("ProfileShape", String.Empty); - obj.Shape.HollowShape = (HollowShape)reader.ReadElementContentAsInt("HollowShape", String.Empty); - - UUID sculptTexture = ReadUUID(reader, "SculptTexture"); - SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty); - if (sculptTexture != UUID.Zero) - { - obj.Shape.SculptTexture = sculptTexture; - obj.Shape.SculptType = (byte)sculptType; - } - - reader.ReadInnerXml(); // SculptData - - obj.Shape.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty); - obj.Shape.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty); - obj.Shape.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty); - obj.Shape.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty); - obj.Shape.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty); - obj.Shape.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty); - obj.Shape.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty); - obj.Shape.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty); - - obj.Shape.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty); - obj.Shape.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty); - obj.Shape.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty); - obj.Shape.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty); - obj.Shape.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty); - obj.Shape.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty); - obj.Shape.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty); - obj.Shape.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty); - - bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); - bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); - reader.ReadInnerXml(); // SculptEntry - - reader.ReadEndElement(); - - obj.Scale = ReadVector(reader, "Scale"); // Yes, again - obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); // UpdateFlag - - obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); - obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); - obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); - obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); - obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty); - obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); - int category = reader.ReadElementContentAsInt("Category", String.Empty); - obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); - obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty); - int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty); - obj.GroupID = ReadUUID(reader, "GroupID"); - obj.OwnerID = ReadUUID(reader, "OwnerID"); - obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); - obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty); - obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty); - obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty); - obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty); - obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty); - - obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("Flags", String.Empty); - - obj.CollisionSound = ReadUUID(reader, "CollisionSound"); - obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); - - reader.ReadEndElement(); - - obj.GroupPosition = groupPosition; - obj.OffsetPosition = offsetPosition; - - return obj; - } - public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) { SceneObjectPart obj = new SceneObjectPart(); -- cgit v1.1 From 3384f643ebbc377ecbaae885941a08484bf259f5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 02:19:42 -0400 Subject: * Partially complete stuff for Mesh support that Melanie wanted to see before it was done. * Shouldn't break the build. * Doesn't work yet either. --- .../CoreModules/Avatar/Assets/GetMeshModule.cs | 201 +++++++++++++++++ .../Avatar/Assets/UploadObjectAssetModule.cs | 248 +++++++++++++++++++++ 2 files changed, 449 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs create mode 100644 OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs new file mode 100644 index 0000000..c1e9891 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -0,0 +1,201 @@ +/* + * 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 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; + +namespace OpenSim.Region.CoreModules.Avatar.Assets +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class GetMeshModule : INonSharedRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + private IAssetService m_assetService; + + #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_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "GetMeshModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capID = UUID.Random(); + + m_log.Info("[GETMESH]: /CAPS/" + capID); + caps.RegisterHandler("GetMesh", + new RestHTTPHandler("POST", "/CAPS/" + capID + "/", + delegate(Hashtable m_dhttpMethod) + { + return ProcessGetMesh(m_dhttpMethod, agentID, caps); + })); + + } + + #endregion + public Hashtable ProcessGetMesh(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"; + + string meshStr = string.Empty; + + if (request.ContainsKey("mesh_id")) + meshStr = request["mesh_id"].ToString(); + + + UUID meshID = UUID.Zero; + if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID)) + { + if (m_assetService == null) + { + responsedata["int_response_code"] = 404; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; + return responsedata; + } + + AssetBase mesh; + // Only try to fetch locally cached textures. Misses are redirected + mesh = m_assetService.GetCached(meshID.ToString()); + if (mesh != null) + { + if (mesh.Type == (sbyte)45) //TODO: Change to AssetType.Mesh when libomv gets updated! + { + responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); + responsedata["content_type"] = "application/vnd.ll.mesh"; + responsedata["int_response_code"] = 200; + } + // Optionally add additional mesh types here + else + { + responsedata["int_response_code"] = 404; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; + return responsedata; + } + } + else + { + mesh = m_assetService.Get(meshID.ToString()); + if (mesh != null) + { + if (mesh.Type == (sbyte)45) //TODO: Change to AssetType.Mesh when libomv gets updated! + { + responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); + responsedata["content_type"] = "application/vnd.ll.mesh"; + responsedata["int_response_code"] = 200; + } + // Optionally add additional mesh types here + else + { + responsedata["int_response_code"] = 404; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; + return responsedata; + } + } + + else + { + responsedata["int_response_code"] = 404; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; + return responsedata; + } + } + + } + + return responsedata; + } + } +} diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs new file mode 100644 index 0000000..2600506 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs @@ -0,0 +1,248 @@ +/* + * 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 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 OpenSim.Framework.Capabilities; + +namespace OpenSim.Region.CoreModules.Avatar.Assets +{ + [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; + private IAssetService m_assetService; + private bool m_dumpAssetsToFile = false; + + #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_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "UploadObjectAssetModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capID = UUID.Random(); + + m_log.Info("[GETMESH]: /CAPS/" + capID); + caps.RegisterHandler("UploadObjectAsset", + + new LLSDStreamhandler("POST", + "/CAPS/" + capID.ToString(), + delegate(LLSDAssetUploadRequest req) + { + return NewAgentInventoryRequest(req,agentID); + })); + + } + + #endregion + + public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) + { + //if (llsdRequest.asset_type == "texture" || + // llsdRequest.asset_type == "animation" || + // llsdRequest.asset_type == "sound") + // { + IClientAPI client = null; + + + IMoneyModule mm = m_scene.RequestModuleInterface(); + + if (mm != null) + { + if (m_scene.TryGetClient(agentID, out client)) + { + if (!mm.UploadCovered(client, mm.UploadCharge)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + } + // } + + + + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; + string capsBase = "/CAPS/UploadObjectAsset/"; + UUID newAsset = UUID.Random(); + UUID newInvItem = UUID.Random(); + UUID parentFolder = llsdRequest.folder_id; + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + Caps.AssetUploader uploader = + new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); + MainServer.Instance.AddStreamHandler( + new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + + string protocol = "http://"; + + if (MainServer.Instance.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + + uploaderPath; + + LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); + uploadResponse.uploader = uploaderURL; + uploadResponse.state = "upload"; + + uploader.OnUpLoad += delegate( + string passetName, string passetDescription, UUID passetID, + UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, + string passetType) + { + UploadCompleteHandler(passetName, passetDescription, passetID, + pinventoryItem, pparentFolder, pdata, pinventoryType, + passetType,agentID); + }; + return uploadResponse; + } + + + public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType,UUID AgentID) + { + sbyte assType = 0; + sbyte inType = 0; + + if (inventoryType == "sound") + { + inType = 1; + assType = 1; + } + else if (inventoryType == "animation") + { + inType = 19; + assType = 20; + } + else if (inventoryType == "wearable") + { + inType = 18; + switch (assetType) + { + case "bodypart": + assType = 13; + break; + case "clothing": + assType = 5; + break; + } + } + + AssetBase asset; + asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); + asset.Data = data; + + if (m_scene.AssetService != null) + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Owner = AgentID; + item.CreatorId = AgentID.ToString(); + item.ID = inventoryItem; + item.AssetID = asset.FullID; + item.Description = assetDescription; + item.Name = assetName; + item.AssetType = assType; + item.InvType = inType; + item.Folder = parentFolder; + item.CurrentPermissions = 2147483647; + item.BasePermissions = 2147483647; + item.EveryOnePermissions = 0; + item.NextPermissions = 2147483647; + item.CreationDate = Util.UnixTimeSinceEpoch(); + m_scene.AddInventoryItem(item); + + } + } +} -- cgit v1.1 From b4a5ce148cf209b1bc0a1ca302275f44abf1040f Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 03:22:14 -0400 Subject: Rename file + more testing and tweaking --- .../NewFileAgentInventoryVariablePriceModule.cs | 256 +++++++++++++++++++++ .../Avatar/Assets/UploadObjectAssetModule.cs | 248 -------------------- 2 files changed, 256 insertions(+), 248 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs delete mode 100644 OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs new file mode 100644 index 0000000..0bba7d4 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -0,0 +1,256 @@ +/* + * 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 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 OpenSim.Framework.Capabilities; + +namespace OpenSim.Region.CoreModules.Avatar.Assets +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + private IAssetService m_assetService; + private bool m_dumpAssetsToFile = false; + + #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_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capID = UUID.Random(); + + m_log.Info("[GETMESH]: /CAPS/" + capID); + caps.RegisterHandler("NewFileAgentInventoryVariablePrice", + + new LLSDStreamhandler("POST", + "/CAPS/" + capID.ToString(), + delegate(LLSDAssetUploadRequest req) + { + return NewAgentInventoryRequest(req,agentID); + })); + + } + + #endregion + + public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) + { + //if (llsdRequest.asset_type == "texture" || + // llsdRequest.asset_type == "animation" || + // llsdRequest.asset_type == "sound") + // { + IClientAPI client = null; + + + IMoneyModule mm = m_scene.RequestModuleInterface(); + + if (mm != null) + { + if (m_scene.TryGetClient(agentID, out client)) + { + if (!mm.UploadCovered(client, mm.UploadCharge)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + } + // } + + + + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; + string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; + UUID newAsset = UUID.Random(); + UUID newInvItem = UUID.Random(); + UUID parentFolder = llsdRequest.folder_id; + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; + + Caps.AssetUploader uploader = + new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); + MainServer.Instance.AddStreamHandler( + new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + + string protocol = "http://"; + + if (MainServer.Instance.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + + uploaderPath; + + LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); + uploadResponse.uploader = uploaderURL; + uploadResponse.state = "upload"; + + uploader.OnUpLoad += UploadCompleteHandler; + + /*delegate( + string passetName, string passetDescription, UUID passetID, + UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, + string passetType) + { + UploadCompleteHandler(passetName, passetDescription, passetID, + pinventoryItem, pparentFolder, pdata, pinventoryType, + passetType,agentID); + };*/ + return uploadResponse; + } + + + public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType) + { + UUID AgentID = UUID.Zero; + sbyte assType = 0; + sbyte inType = 0; + + if (inventoryType == "sound") + { + inType = 1; + assType = 1; + } + else if (inventoryType == "animation") + { + inType = 19; + assType = 20; + } + else if (inventoryType == "wearable") + { + inType = 18; + switch (assetType) + { + case "bodypart": + assType = 13; + break; + case "clothing": + assType = 5; + break; + } + } + else if (inventoryType == "mesh") + { + inType = 45; // TODO: Replace with appropriate type + assType = 45;// TODO: Replace with appropriate type + } + + AssetBase asset; + asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); + asset.Data = data; + + if (m_scene.AssetService != null) + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Owner = AgentID; + item.CreatorId = AgentID.ToString(); + item.ID = inventoryItem; + item.AssetID = asset.FullID; + item.Description = assetDescription; + item.Name = assetName; + item.AssetType = assType; + item.InvType = inType; + item.Folder = parentFolder; + item.CurrentPermissions = 2147483647; + item.BasePermissions = 2147483647; + item.EveryOnePermissions = 0; + item.NextPermissions = 2147483647; + item.CreationDate = Util.UnixTimeSinceEpoch(); + m_scene.AddInventoryItem(item); + + } + } +} diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs deleted file mode 100644 index 2600506..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Assets/UploadObjectAssetModule.cs +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 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 OpenSim.Framework.Capabilities; - -namespace OpenSim.Region.CoreModules.Avatar.Assets -{ - [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; - private IAssetService m_assetService; - private bool m_dumpAssetsToFile = false; - - #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_assetService = m_scene.RequestModuleInterface(); - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - } - - #endregion - - - #region IRegionModule Members - - - - public void Close() { } - - public string Name { get { return "UploadObjectAssetModule"; } } - - - public void RegisterCaps(UUID agentID, Caps caps) - { - UUID capID = UUID.Random(); - - m_log.Info("[GETMESH]: /CAPS/" + capID); - caps.RegisterHandler("UploadObjectAsset", - - new LLSDStreamhandler("POST", - "/CAPS/" + capID.ToString(), - delegate(LLSDAssetUploadRequest req) - { - return NewAgentInventoryRequest(req,agentID); - })); - - } - - #endregion - - public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) - { - //if (llsdRequest.asset_type == "texture" || - // llsdRequest.asset_type == "animation" || - // llsdRequest.asset_type == "sound") - // { - IClientAPI client = null; - - - IMoneyModule mm = m_scene.RequestModuleInterface(); - - if (mm != null) - { - if (m_scene.TryGetClient(agentID, out client)) - { - if (!mm.UploadCovered(client, mm.UploadCharge)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - } - // } - - - - string assetName = llsdRequest.name; - string assetDes = llsdRequest.description; - string capsBase = "/CAPS/UploadObjectAsset/"; - UUID newAsset = UUID.Random(); - UUID newInvItem = UUID.Random(); - UUID parentFolder = llsdRequest.folder_id; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - Caps.AssetUploader uploader = - new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); - MainServer.Instance.AddStreamHandler( - new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - - string protocol = "http://"; - - if (MainServer.Instance.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + - uploaderPath; - - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; - uploadResponse.state = "upload"; - - uploader.OnUpLoad += delegate( - string passetName, string passetDescription, UUID passetID, - UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, - string passetType) - { - UploadCompleteHandler(passetName, passetDescription, passetID, - pinventoryItem, pparentFolder, pdata, pinventoryType, - passetType,agentID); - }; - return uploadResponse; - } - - - public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType,UUID AgentID) - { - sbyte assType = 0; - sbyte inType = 0; - - if (inventoryType == "sound") - { - inType = 1; - assType = 1; - } - else if (inventoryType == "animation") - { - inType = 19; - assType = 20; - } - else if (inventoryType == "wearable") - { - inType = 18; - switch (assetType) - { - case "bodypart": - assType = 13; - break; - case "clothing": - assType = 5; - break; - } - } - - AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); - asset.Data = data; - - if (m_scene.AssetService != null) - m_scene.AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Owner = AgentID; - item.CreatorId = AgentID.ToString(); - item.ID = inventoryItem; - item.AssetID = asset.FullID; - item.Description = assetDescription; - item.Name = assetName; - item.AssetType = assType; - item.InvType = inType; - item.Folder = parentFolder; - item.CurrentPermissions = 2147483647; - item.BasePermissions = 2147483647; - item.EveryOnePermissions = 0; - item.NextPermissions = 2147483647; - item.CreationDate = Util.UnixTimeSinceEpoch(); - m_scene.AddInventoryItem(item); - - } - } -} -- cgit v1.1 From 7e363b79c7894b8c393ec38ae60ea19f8cb65d5e Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 09:24:15 -0400 Subject: * Tweaked the upload response and now at least uploading the mesh works. * Binary error on downloading the mesh though.. so still not yet working. --- .../CoreModules/Avatar/Assets/GetMeshModule.cs | 4 +-- .../NewFileAgentInventoryVariablePriceModule.cs | 33 +++++++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index c1e9891..bae108c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -145,7 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets mesh = m_assetService.GetCached(meshID.ToString()); if (mesh != null) { - if (mesh.Type == (sbyte)45) //TODO: Change to AssetType.Mesh when libomv gets updated! + if (mesh.Type == (sbyte)49) //TODO: Change to AssetType.Mesh when libomv gets updated! { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; @@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets mesh = m_assetService.Get(meshID.ToString()); if (mesh != null) { - if (mesh.Type == (sbyte)45) //TODO: Change to AssetType.Mesh when libomv gets updated! + if (mesh.Type == (sbyte)49) //TODO: Change to AssetType.Mesh when libomv gets updated! { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index 0bba7d4..9029f58 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets m_log.Info("[GETMESH]: /CAPS/" + capID); caps.RegisterHandler("NewFileAgentInventoryVariablePrice", - new LLSDStreamhandler("POST", + new LLSDStreamhandler("POST", "/CAPS/" + capID.ToString(), delegate(LLSDAssetUploadRequest req) { @@ -117,8 +117,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets } #endregion - - public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) + + public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) { //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || @@ -138,8 +138,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; errorResponse.state = "error"; return errorResponse; } @@ -170,14 +170,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + uploaderPath; + - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; + LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + + + uploadResponse.rsvp = uploaderURL; uploadResponse.state = "upload"; + uploadResponse.resource_cost = 0; + uploadResponse.upload_price = 0; - uploader.OnUpLoad += UploadCompleteHandler; + uploader.OnUpLoad += //UploadCompleteHandler; - /*delegate( + delegate( string passetName, string passetDescription, UUID passetID, UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, string passetType) @@ -185,16 +190,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets UploadCompleteHandler(passetName, passetDescription, passetID, pinventoryItem, pparentFolder, pdata, pinventoryType, passetType,agentID); - };*/ + }; return uploadResponse; } public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) + string assetType,UUID AgentID) { - UUID AgentID = UUID.Zero; + sbyte assType = 0; sbyte inType = 0; @@ -223,8 +228,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets } else if (inventoryType == "mesh") { - inType = 45; // TODO: Replace with appropriate type - assType = 45;// TODO: Replace with appropriate type + inType = 22; // TODO: Replace with appropriate type + assType = 49;// TODO: Replace with appropriate type } AssetBase asset; -- cgit v1.1 From 6d99f0c627d9f1eefd14b7488cce34b1e2e7d933 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 09:34:37 -0400 Subject: * Whoops, That was supposed to use the HTTP VERB 'GET' not 'POST' * At this point. Visually, Mesh works OK. Remember peeps, this is still highly experimental from the viewer side as well as the Simulator side. There are known problems with the new beta viewers and attachment breaking so be careful until that's fixed. Additionally there some new properties in the Mesh Viewer that determine physics settings that are non-functional. More work will be done on that. --- OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index bae108c..a090c0c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets m_log.Info("[GETMESH]: /CAPS/" + capID); caps.RegisterHandler("GetMesh", - new RestHTTPHandler("POST", "/CAPS/" + capID + "/", + new RestHTTPHandler("GET", "/CAPS/" + capID, delegate(Hashtable m_dhttpMethod) { return ProcessGetMesh(m_dhttpMethod, agentID, caps); -- cgit v1.1 From 05c4e27a30e9bfa4657aac911ddbb69cafe3c9a0 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 09:57:42 -0400 Subject: * A few additional cleanup elements * At this point, I want to make sure to thank the fabulous developers of the LibOpenMetaverse library for tirelessly keeping things updated and hammering away at the protocols and providing excellent tools to figure out where things go wrong. * Special thanks to John Hurliman and Latif Khalifa for their valuable insight. --- OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | 1 + .../Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index a090c0c..b8aed0b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -113,6 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets } #endregion + public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) { diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index 9029f58..35f054f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -120,6 +120,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) { + + //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit + // You need to be aware of this and + + //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") -- cgit v1.1 From 41ce392d9b32c343c5239b3a9fa0ef9f83b6a96f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 14 Oct 2010 09:05:46 -0700 Subject: Added manual xml2 serialization. Rewired only save xml2, not oars yet. Seems to be generating xml's that are successfully parsed. Needs more testing. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 261 +++++++++++++-------- .../Scenes/Serialization/SceneXmlLoader.cs | 8 +- 2 files changed, 164 insertions(+), 105 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index efd5a8e..6e3b15a 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -316,7 +316,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("FolderID", ProcessFolderID); m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial); m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory); - m_SOPXmlProcessors.Add("ObjectFlags", ProcessObjectFlags); m_SOPXmlProcessors.Add("UUID", ProcessUUID); m_SOPXmlProcessors.Add("LocalId", ProcessLocalId); m_SOPXmlProcessors.Add("Name", ProcessName); @@ -467,11 +466,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory"); } - private static void ProcessObjectFlags(SceneObjectPart obj, XmlTextReader reader) - { - obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); - } - private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) { obj.UUID = ReadUUID(reader, "UUID"); @@ -1089,7 +1083,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization sog.ForEachPart(delegate(SceneObjectPart sop) { - SOPToXml2(writer, sop, sog.RootPart); + if (sop.UUID != sog.RootPart.UUID) + SOPToXml2(writer, sop, sog.RootPart); }); writer.WriteEndElement(); @@ -1102,19 +1097,18 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); + writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower()); WriteUUID(writer, "CreatorID", sop.CreatorID); WriteUUID(writer, "FolderID", sop.FolderID); - writer.WriteElementString("InventorySerial", (sop.Inventory != null) ? sop.InventorySerial.ToString() : "0"); + writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString()); - // FIXME: Task inventory - writer.WriteStartElement("TaskInventory"); writer.WriteEndElement(); - - writer.WriteElementString("ObjectFlags", ((int)sop.Flags).ToString()); + WriteTaskInventory(writer, sop.TaskInventory); WriteUUID(writer, "UUID", sop.UUID); writer.WriteElementString("LocalId", sop.LocalId.ToString()); writer.WriteElementString("Name", sop.Name); - writer.WriteElementString("Material", ((int)sop.Material).ToString()); + writer.WriteElementString("Material", sop.Material.ToString()); + writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower()); writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString()); writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString()); @@ -1123,115 +1117,40 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteQuaternion(writer, "RotationOffset", sop.RotationOffset); WriteVector(writer, "Velocity", sop.Velocity); - WriteVector(writer, "RotationalVelocity", Vector3.Zero); WriteVector(writer, "AngularVelocity", sop.AngularVelocity); WriteVector(writer, "Acceleration", sop.Acceleration); writer.WriteElementString("Description", sop.Description); - writer.WriteStartElement("Color"); - writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); - writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); - writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); - writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); - writer.WriteEndElement(); + if (sop.Color != null) + { + writer.WriteStartElement("Color"); + writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); + writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); + writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); + writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + writer.WriteElementString("Text", sop.Text); writer.WriteElementString("SitName", sop.SitName); writer.WriteElementString("TouchName", sop.TouchName); writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); - writer.WriteStartElement("Shape"); - writer.WriteElementString("ProfileCurve", sop.Shape.ProfileCurve.ToString()); - - writer.WriteStartElement("TextureEntry"); - byte[] te; - if (sop.Shape.TextureEntry != null) - te = sop.Shape.TextureEntry; - else - te = Utils.EmptyBytes; - writer.WriteBase64(te, 0, te.Length); - writer.WriteEndElement(); // TextureEntry - - writer.WriteStartElement("ExtraParams"); - byte[] ep; - if (sop.Shape.ExtraParams != null) - ep = sop.Shape.ExtraParams; - else - ep = Utils.EmptyBytes; - writer.WriteBase64(ep, 0, ep.Length); - writer.WriteEndElement(); // ExtraParams - - writer.WriteElementString("PathBegin", Primitive.PackBeginCut(sop.Shape.PathBegin).ToString()); - writer.WriteElementString("PathCurve", sop.Shape.PathCurve.ToString()); - writer.WriteElementString("PathEnd", Primitive.PackEndCut(sop.Shape.PathEnd).ToString()); - writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(sop.Shape.PathRadiusOffset).ToString()); - writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(sop.Shape.PathRevolutions).ToString()); - writer.WriteElementString("PathScaleX", Primitive.PackPathScale(sop.Shape.PathScaleX).ToString()); - writer.WriteElementString("PathScaleY", Primitive.PackPathScale(sop.Shape.PathScaleY).ToString()); - writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(sop.Shape.PathShearX)).ToString()); - writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(sop.Shape.PathShearY)).ToString()); - writer.WriteElementString("PathSkew", Primitive.PackPathTwist(sop.Shape.PathSkew).ToString()); - writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(sop.Shape.PathTaperX).ToString()); - writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(sop.Shape.PathTaperY).ToString()); - writer.WriteElementString("PathTwist", Primitive.PackPathTwist(sop.Shape.PathTwist).ToString()); - writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(sop.Shape.PathTwistBegin).ToString()); - writer.WriteElementString("PCode", sop.Shape.PCode.ToString()); - writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(sop.Shape.ProfileBegin).ToString()); - writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(sop.Shape.ProfileEnd).ToString()); - writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(sop.Shape.ProfileHollow).ToString()); - WriteVector(writer, "Scale", sop.Scale); - writer.WriteElementString("State", sop.Shape.State.ToString()); - - writer.WriteElementString("ProfileShape", sop.Shape.ProfileShape.ToString()); - writer.WriteElementString("HollowShape", sop.Shape.HollowShape.ToString()); - - writer.WriteElementString("SculptTexture", sop.Shape.SculptTexture.ToString()); - writer.WriteElementString("SculptType", sop.Shape.SculptType.ToString()); - writer.WriteStartElement("SculptData"); - byte[] sd; - if (sop.Shape.SculptData != null) - sd = sop.Shape.ExtraParams; - else - sd = Utils.EmptyBytes; - writer.WriteBase64(sd, 0, sd.Length); - writer.WriteEndElement(); // SculptData - - writer.WriteElementString("FlexiSoftness", sop.Shape.FlexiSoftness.ToString()); - writer.WriteElementString("FlexiTension", sop.Shape.FlexiTension.ToString()); - writer.WriteElementString("FlexiDrag", sop.Shape.FlexiDrag.ToString()); - writer.WriteElementString("FlexiGravity", sop.Shape.FlexiGravity.ToString()); - writer.WriteElementString("FlexiWind", sop.Shape.FlexiWind.ToString()); - writer.WriteElementString("FlexiForceX", sop.Shape.FlexiForceX.ToString()); - writer.WriteElementString("FlexiForceY", sop.Shape.FlexiForceY.ToString()); - writer.WriteElementString("FlexiForceZ", sop.Shape.FlexiForceZ.ToString()); - - writer.WriteElementString("LightColorR", sop.Shape.LightColorR.ToString()); - writer.WriteElementString("LightColorG", sop.Shape.LightColorG.ToString()); - writer.WriteElementString("LightColorB", sop.Shape.LightColorB.ToString()); - writer.WriteElementString("LightColorA", sop.Shape.LightColorA.ToString()); - writer.WriteElementString("LightRadius", sop.Shape.LightRadius.ToString()); - writer.WriteElementString("LightCutoff", sop.Shape.LightCutoff.ToString()); - writer.WriteElementString("LightFalloff", sop.Shape.LightFalloff.ToString()); - writer.WriteElementString("LightIntensity", sop.Shape.LightIntensity.ToString()); - - writer.WriteElementString("FlexyEntry", sop.Shape.FlexiEntry.ToString()); - writer.WriteElementString("LightEntry", sop.Shape.LightEntry.ToString()); - writer.WriteElementString("SculptEntry", sop.Shape.SculptEntry.ToString()); - - writer.WriteEndElement(); // Shape + WriteShape(writer, sop.Shape); WriteVector(writer, "Scale", sop.Scale); - writer.WriteElementString("UpdateFlag", "0"); + writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString()); WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation); WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition); WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL); WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL); writer.WriteElementString("ParentID", sop.ParentID.ToString()); writer.WriteElementString("CreationDate", sop.CreationDate.ToString()); - writer.WriteElementString("Category", "0"); + writer.WriteElementString("Category", sop.Category.ToString()); writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); - writer.WriteElementString("ObjectSaleType", ((int)sop.ObjectSaleType).ToString()); - writer.WriteElementString("OwnershipCost", "0"); + writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); + writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); WriteUUID(writer, "GroupID", sop.GroupID); WriteUUID(writer, "OwnerID", sop.OwnerID); WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); @@ -1243,6 +1162,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Flags", sop.Flags.ToString()); WriteUUID(writer, "CollisionSound", sop.CollisionSound); writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); + if (sop.MediaUrl != null) + writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); writer.WriteEndElement(); } @@ -1273,6 +1194,134 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); } + static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv) + { + if (tinv.Count > 0) // otherwise skip this + { + writer.WriteStartElement("TaskInventory"); + + foreach (TaskInventoryItem item in tinv.Values) + { + writer.WriteStartElement("TaskInventoryItem"); + + WriteUUID(writer, "AssetID", item.AssetID); + writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); + writer.WriteElementString("CreationDate", item.CreationDate.ToString()); + WriteUUID(writer, "CreatorID", item.CreatorID); + writer.WriteElementString("Description", item.Description); + writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); + writer.WriteElementString("Flags", item.Flags.ToString()); + WriteUUID(writer, "GroupID", item.GroupID); + writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); + writer.WriteElementString("InvType", item.InvType.ToString()); + WriteUUID(writer, "ItemID", item.ItemID); + WriteUUID(writer, "OldItemID", item.OldItemID); + WriteUUID(writer, "LastOwnerID", item.LastOwnerID); + writer.WriteElementString("Name", item.Name); + writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); + WriteUUID(writer, "OwnerID", item.OwnerID); + writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); + WriteUUID(writer, "ParentID", item.ParentID); + WriteUUID(writer, "ParentPartID", item.ParentPartID); + WriteUUID(writer, "PermsGranter", item.PermsGranter); + writer.WriteElementString("PermsMask", item.PermsMask.ToString()); + writer.WriteElementString("Type", item.Type.ToString()); + + writer.WriteEndElement(); // TaskInventoryItem + } + + writer.WriteEndElement(); // TaskInventory + } + } + + static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp) + { + if (shp != null) + { + writer.WriteStartElement("Shape"); + + writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString()); + + writer.WriteStartElement("TextureEntry"); + byte[] te; + if (shp.TextureEntry != null) + te = shp.TextureEntry; + else + te = Utils.EmptyBytes; + writer.WriteBase64(te, 0, te.Length); + writer.WriteEndElement(); // TextureEntry + + writer.WriteStartElement("ExtraParams"); + byte[] ep; + if (shp.ExtraParams != null) + ep = shp.ExtraParams; + else + ep = Utils.EmptyBytes; + writer.WriteBase64(ep, 0, ep.Length); + writer.WriteEndElement(); // ExtraParams + + writer.WriteElementString("PathBegin", shp.PathBegin.ToString()); + writer.WriteElementString("PathCurve", shp.PathCurve.ToString()); + writer.WriteElementString("PathEnd", shp.PathEnd.ToString()); + writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString()); + writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString()); + writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString()); + writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString()); + writer.WriteElementString("PathShearX", shp.PathShearX.ToString()); + writer.WriteElementString("PathShearY", shp.PathShearY.ToString()); + writer.WriteElementString("PathSkew", shp.PathSkew.ToString()); + writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString()); + writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString()); + writer.WriteElementString("PathTwist", shp.PathTwist.ToString()); + writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString()); + writer.WriteElementString("PCode", shp.PCode.ToString()); + writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString()); + writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString()); + writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString()); + writer.WriteElementString("State", shp.State.ToString()); + + writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString()); + writer.WriteElementString("HollowShape", shp.HollowShape.ToString()); + + WriteUUID(writer, "SculptTexture", shp.SculptTexture); + writer.WriteElementString("SculptType", shp.SculptType.ToString()); + writer.WriteStartElement("SculptData"); + byte[] sd; + if (shp.SculptData != null) + sd = shp.ExtraParams; + else + sd = Utils.EmptyBytes; + writer.WriteBase64(sd, 0, sd.Length); + writer.WriteEndElement(); // SculptData + + writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString()); + writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString()); + writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString()); + writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString()); + writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString()); + writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString()); + writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString()); + writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString()); + + writer.WriteElementString("LightColorR", shp.LightColorR.ToString()); + writer.WriteElementString("LightColorG", shp.LightColorG.ToString()); + writer.WriteElementString("LightColorB", shp.LightColorB.ToString()); + writer.WriteElementString("LightColorA", shp.LightColorA.ToString()); + writer.WriteElementString("LightRadius", shp.LightRadius.ToString()); + writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString()); + writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString()); + writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString()); + + writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower()); + writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower()); + writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower()); + + if (shp.Media != null) + writer.WriteElementString("Media", shp.Media.ToXml()); + + writer.WriteEndElement(); // Shape + } + } //////// Read ///////// public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) @@ -1332,13 +1381,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization SOPXmlProcessor p = null; if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p)) { + //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name); try { p(obj, reader); } catch (Exception e) { - m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0} in {1}-{2}: {3}", nodeName, obj.Name, obj.UUID, e); + m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0}: {1}", nodeName, e); + if (reader.NodeType == XmlNodeType.EndElement) + reader.Read(); } } else @@ -1441,6 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization while (reader.NodeType != XmlNodeType.EndElement) { + //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name); ShapeXmlProcessor p = null; if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p)) p(shape, reader); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index bb67ca0..c6d4e55 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -280,6 +280,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) { + XmlTextWriter writer = new XmlTextWriter(stream); + int primCount = 0; stream.WriteLine("\n"); @@ -297,10 +299,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization continue; } - stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); + //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); + SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent); + stream.WriteLine(); + primCount++; } } + stream.WriteLine("\n"); stream.Flush(); } -- cgit v1.1 From ba247f729d80dbc01b1cc13cc46692691b4b4cb3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 14 Oct 2010 11:08:10 +0100 Subject: Kill some magic numbers in the mesh upload module and change the mesh asset type from 45 to 49 to match OMV trunk --- .../Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index 35f054f..d644cdd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -254,10 +254,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets item.AssetType = assType; item.InvType = inType; item.Folder = parentFolder; - item.CurrentPermissions = 2147483647; - item.BasePermissions = 2147483647; + item.CurrentPermissions = (uint)PermissionMask.All; + item.BasePermissions = (uint)PermissionMask.All; item.EveryOnePermissions = 0; - item.NextPermissions = 2147483647; + item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); item.CreationDate = Util.UnixTimeSinceEpoch(); m_scene.AddInventoryItem(item); -- cgit v1.1 From 405935492ba360806fd47fa2053601bc98969d0d Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Thu, 14 Oct 2010 18:08:59 +0200 Subject: Don't distroy attachments when using viewer 2.1+, strip multiple attachment data --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 457e0bb..51197d2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -228,6 +228,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); + // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should + // be removed when that functionality is implemented in opensim + AttachmentPt &= 0x7f; + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); if (updateInventoryStatus) -- cgit v1.1 From c148ef25a9fcb5236731e949f6c6dbf042d07ef9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 12:23:41 -0400 Subject: * Replacing Magic numbers with Enums --- OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | 4 ++-- .../Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index b8aed0b..36aaab3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets mesh = m_assetService.GetCached(meshID.ToString()); if (mesh != null) { - if (mesh.Type == (sbyte)49) //TODO: Change to AssetType.Mesh when libomv gets updated! + if (mesh.Type == (SByte)AssetType.Mesh) { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; @@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets mesh = m_assetService.Get(meshID.ToString()); if (mesh != null) { - if (mesh.Type == (sbyte)49) //TODO: Change to AssetType.Mesh when libomv gets updated! + if (mesh.Type == (SByte)AssetType.Mesh) { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index 35f054f..0d26036 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -233,8 +233,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets } else if (inventoryType == "mesh") { - inType = 22; // TODO: Replace with appropriate type - assType = 49;// TODO: Replace with appropriate type + inType = (sbyte)InventoryType.Mesh; + assType = (sbyte)AssetType.Mesh; } AssetBase asset; -- cgit v1.1 From 2d88394cd59d9bf747b77c242b75bd923b0bc5af Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 14 Oct 2010 13:10:03 -0700 Subject: laying some groundwork for mesh physics --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 150 ++++++++++++++------------ 1 file changed, 80 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index cf57c0a..e1203ea 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -256,102 +256,112 @@ namespace OpenSim.Region.Physics.Meshing PrimMesh primMesh; PrimMesher.SculptMesh sculptMesh; - List coords; - List faces; + List coords = new List(); + List faces = new List(); Image idata = null; string decodedSculptFileName = ""; if (primShape.SculptEntry) { - if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero) + if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh) + { + // add code for mesh physics proxy generation here + m_log.Debug("[MESH]: mesh proxy generation not implemented yet "); + return null; + + } + else { - decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString()); - try + if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero) { - if (File.Exists(decodedSculptFileName)) + decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString()); + try { - idata = Image.FromFile(decodedSculptFileName); + if (File.Exists(decodedSculptFileName)) + { + idata = Image.FromFile(decodedSculptFileName); + } } - } - catch (Exception e) - { - m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message); + catch (Exception e) + { + m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message); + } + //if (idata != null) + // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString()); } - //if (idata != null) - // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString()); - } - if (idata == null) - { - if (primShape.SculptData == null || primShape.SculptData.Length == 0) - return null; - - try + if (idata == null) { - OpenMetaverse.Imaging.ManagedImage unusedData; - OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); - unusedData = null; + if (primShape.SculptData == null || primShape.SculptData.Length == 0) + return null; + + try + { + OpenMetaverse.Imaging.ManagedImage unusedData; + OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); + unusedData = null; - //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); + //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); - if (cacheSculptMaps && idata != null) + if (cacheSculptMaps && idata != null) + { + try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } + catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } + } + } + catch (DllNotFoundException) { - try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } - catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } + m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!"); + return null; + } + catch (IndexOutOfRangeException) + { + m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); + return null; + } + catch (Exception ex) + { + m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); + return null; } } - catch (DllNotFoundException) - { - m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!"); - return null; - } - catch (IndexOutOfRangeException) - { - m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); - return null; - } - catch (Exception ex) + + PrimMesher.SculptMesh.SculptType sculptType; + switch ((OpenMetaverse.SculptType)primShape.SculptType) { - m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); - return null; + case OpenMetaverse.SculptType.Cylinder: + sculptType = PrimMesher.SculptMesh.SculptType.cylinder; + break; + case OpenMetaverse.SculptType.Plane: + sculptType = PrimMesher.SculptMesh.SculptType.plane; + break; + case OpenMetaverse.SculptType.Torus: + sculptType = PrimMesher.SculptMesh.SculptType.torus; + break; + case OpenMetaverse.SculptType.Sphere: + sculptType = PrimMesher.SculptMesh.SculptType.sphere; + break; + default: + sculptType = PrimMesher.SculptMesh.SculptType.plane; + break; } - } - PrimMesher.SculptMesh.SculptType sculptType; - switch ((OpenMetaverse.SculptType)primShape.SculptType) - { - case OpenMetaverse.SculptType.Cylinder: - sculptType = PrimMesher.SculptMesh.SculptType.cylinder; - break; - case OpenMetaverse.SculptType.Plane: - sculptType = PrimMesher.SculptMesh.SculptType.plane; - break; - case OpenMetaverse.SculptType.Torus: - sculptType = PrimMesher.SculptMesh.SculptType.torus; - break; - case OpenMetaverse.SculptType.Sphere: - sculptType = PrimMesher.SculptMesh.SculptType.sphere; - break; - default: - sculptType = PrimMesher.SculptMesh.SculptType.plane; - break; - } + bool mirror = ((primShape.SculptType & 128) != 0); + bool invert = ((primShape.SculptType & 64) != 0); - bool mirror = ((primShape.SculptType & 128) != 0); - bool invert = ((primShape.SculptType & 64) != 0); + sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert); + + idata.Dispose(); - sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert); - - idata.Dispose(); + sculptMesh.DumpRaw(baseDir, primName, "primMesh"); - sculptMesh.DumpRaw(baseDir, primName, "primMesh"); + sculptMesh.Scale(size.X, size.Y, size.Z); - sculptMesh.Scale(size.X, size.Y, size.Z); - - coords = sculptMesh.coords; - faces = sculptMesh.faces; + coords = sculptMesh.coords; + faces = sculptMesh.faces; + } } else { -- cgit v1.1 From bcdd03c1cfcfab72d6ee4199bd1232ff3a748d6e Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 14 Oct 2010 20:25:31 -0700 Subject: more work in progress on mesh physics - still non-functional --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 69 ++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index e1203ea..df44be3 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -30,9 +30,11 @@ using System; using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; -using OpenMetaverse; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using System.Drawing; -using System.Drawing.Imaging; +using System.Drawing.Imaging; +using System.IO.Compression; using PrimMesher; using log4net; using Nini.Config; @@ -268,6 +270,69 @@ namespace OpenSim.Region.Physics.Meshing { // add code for mesh physics proxy generation here m_log.Debug("[MESH]: mesh proxy generation not implemented yet "); + + OSD meshOsd; + + if (primShape.SculptData.Length > 0) + { + + + m_log.Debug("[MESH]: asset data length: " + primShape.SculptData.Length.ToString()); + byte[] header = Util.StringToBytes256(""); + + ////dump to debugging file + //string filename = System.IO.Path.Combine(decodedSculptMapPath, "mesh_" + primShape.SculptTexture.ToString()); + //BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create)); + //writer.Write(primShape.SculptData); + //writer.Close(); + + } + else + { + m_log.Error("[MESH]: asset data is zero length"); + return null; + } + + try + { + meshOsd = OSDParser.DeserializeLLSDBinary(primShape.SculptData, true); + } + catch (Exception e) + { + m_log.Error("[MESH]: exception decoding mesh asset: " + e.ToString()); + return null; + } + + if (meshOsd is OSDMap) + { + OSDMap map = (OSDMap)meshOsd; + //foreach (string name in map.Keys) + // m_log.Debug("[MESH]: key:" + name + " value:" + map[name].AsString()); + OSDMap physicsParms = (OSDMap)map["physics_shape"]; + int physOffset = physicsParms["offset"].AsInteger(); + int physSize = physicsParms["size"].AsInteger(); + + if (physOffset < 0 || physSize == 0) + return null; // no mesh data in asset + + m_log.Debug("[MESH]: physOffset:" + physOffset.ToString() + " physSize:" + physSize.ToString()); + //MemoryStream ms = new MemoryStream(primShape.SculptData, physOffset, physSize); + //GZipStream gzStream = new GZipStream(ms, CompressionMode.Decompress); + + //int maxSize = physSize * 5; // arbitrary guess + //byte[] readBuffer = new byte[maxSize]; + + //int bytesRead = gzStream.Read(readBuffer, 0, maxSize); + + //OSD physMeshOsd = OSDParser.DeserializeLLSDBinary(readBuffer); + + + + + + } + + //just bail out for now until mesh code is finished return null; } -- cgit v1.1 From 0308982c58c16bfa005a401d0345b2e58b759c44 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 14 Oct 2010 23:32:33 -0400 Subject: one more silly line ending thing.... *If you have problems, fetch the tree and rebase. Signed-off-by: Teravus Ovares (Dan Olivares) --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 142 +++++++++++++------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index df44be3..3e3a0f0 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -30,10 +30,10 @@ using System; using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; -using OpenMetaverse; +using OpenMetaverse; using OpenMetaverse.StructuredData; using System.Drawing; -using System.Drawing.Imaging; +using System.Drawing.Imaging; using System.IO.Compression; using PrimMesher; using log4net; @@ -266,75 +266,75 @@ namespace OpenSim.Region.Physics.Meshing if (primShape.SculptEntry) { - if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh) - { - // add code for mesh physics proxy generation here - m_log.Debug("[MESH]: mesh proxy generation not implemented yet "); - - OSD meshOsd; - - if (primShape.SculptData.Length > 0) - { - - - m_log.Debug("[MESH]: asset data length: " + primShape.SculptData.Length.ToString()); - byte[] header = Util.StringToBytes256(""); - - ////dump to debugging file - //string filename = System.IO.Path.Combine(decodedSculptMapPath, "mesh_" + primShape.SculptTexture.ToString()); - //BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create)); - //writer.Write(primShape.SculptData); - //writer.Close(); - - } - else - { - m_log.Error("[MESH]: asset data is zero length"); - return null; - } - - try - { - meshOsd = OSDParser.DeserializeLLSDBinary(primShape.SculptData, true); - } - catch (Exception e) - { - m_log.Error("[MESH]: exception decoding mesh asset: " + e.ToString()); - return null; - } - - if (meshOsd is OSDMap) - { - OSDMap map = (OSDMap)meshOsd; - //foreach (string name in map.Keys) - // m_log.Debug("[MESH]: key:" + name + " value:" + map[name].AsString()); - OSDMap physicsParms = (OSDMap)map["physics_shape"]; - int physOffset = physicsParms["offset"].AsInteger(); - int physSize = physicsParms["size"].AsInteger(); - - if (physOffset < 0 || physSize == 0) - return null; // no mesh data in asset - - m_log.Debug("[MESH]: physOffset:" + physOffset.ToString() + " physSize:" + physSize.ToString()); - //MemoryStream ms = new MemoryStream(primShape.SculptData, physOffset, physSize); - //GZipStream gzStream = new GZipStream(ms, CompressionMode.Decompress); - - //int maxSize = physSize * 5; // arbitrary guess - //byte[] readBuffer = new byte[maxSize]; - - //int bytesRead = gzStream.Read(readBuffer, 0, maxSize); - - //OSD physMeshOsd = OSDParser.DeserializeLLSDBinary(readBuffer); - - - - - - } - - //just bail out for now until mesh code is finished - return null; - + if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh) + { + // add code for mesh physics proxy generation here + m_log.Debug("[MESH]: mesh proxy generation not implemented yet "); + + OSD meshOsd; + + if (primShape.SculptData.Length > 0) + { + + + m_log.Debug("[MESH]: asset data length: " + primShape.SculptData.Length.ToString()); + byte[] header = Util.StringToBytes256(""); + + ////dump to debugging file + //string filename = System.IO.Path.Combine(decodedSculptMapPath, "mesh_" + primShape.SculptTexture.ToString()); + //BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create)); + //writer.Write(primShape.SculptData); + //writer.Close(); + + } + else + { + m_log.Error("[MESH]: asset data is zero length"); + return null; + } + + try + { + meshOsd = OSDParser.DeserializeLLSDBinary(primShape.SculptData, true); + } + catch (Exception e) + { + m_log.Error("[MESH]: exception decoding mesh asset: " + e.ToString()); + return null; + } + + if (meshOsd is OSDMap) + { + OSDMap map = (OSDMap)meshOsd; + //foreach (string name in map.Keys) + // m_log.Debug("[MESH]: key:" + name + " value:" + map[name].AsString()); + OSDMap physicsParms = (OSDMap)map["physics_shape"]; + int physOffset = physicsParms["offset"].AsInteger(); + int physSize = physicsParms["size"].AsInteger(); + + if (physOffset < 0 || physSize == 0) + return null; // no mesh data in asset + + m_log.Debug("[MESH]: physOffset:" + physOffset.ToString() + " physSize:" + physSize.ToString()); + //MemoryStream ms = new MemoryStream(primShape.SculptData, physOffset, physSize); + //GZipStream gzStream = new GZipStream(ms, CompressionMode.Decompress); + + //int maxSize = physSize * 5; // arbitrary guess + //byte[] readBuffer = new byte[maxSize]; + + //int bytesRead = gzStream.Read(readBuffer, 0, maxSize); + + //OSD physMeshOsd = OSDParser.DeserializeLLSDBinary(readBuffer); + + + + + + } + + //just bail out for now until mesh code is finished + return null; + } else { -- cgit v1.1 From cd4d7a7c351ad78c13805374b46ea8168568d89e Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Fri, 15 Oct 2010 07:24:57 +0200 Subject: A couple of more ways attachment point is sent Signed-off-by: Teravus Ovares (Dan Olivares) --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 51197d2..2a0c0b1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -113,6 +113,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) return; + // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should + // be removed when that functionality is implemented in opensim + AttachmentPt &= 0x7f; + // Calls attach with a Zero position if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) { @@ -142,6 +146,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) { + // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should + // be removed when that functionality is implemented in opensim + AttachmentPt &= 0x7f; + // If the attachment point isn't the same as the one previously used // set it's offset position = 0 so that it appears on the attachment point // and not in a weird location somewhere unknown. -- cgit v1.1 From 1499607215aab4994f933a8ed2a54ed037a1f9ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 15 Oct 2010 17:27:19 -0700 Subject: Made OARs use the new serialization procedure. (TPs/crossings still on the old one) Added an options argument down the pipeline. For the time being it takes --old-guids as an option to produce instead of . --- OpenSim/Region/Application/OpenSim.cs | 5 +- .../World/Archiver/ArchiveWriteRequestExecution.cs | 7 +- .../Archiver/ArchiveWriteRequestPreparation.cs | 5 +- .../CoreModules/World/Archiver/ArchiverModule.cs | 27 ++- .../World/Serialiser/SerialiserModule.cs | 4 +- .../World/Serialiser/Tests/SerialiserTests.cs | 2 +- .../Framework/Interfaces/IRegionArchiverModule.cs | 5 +- .../Interfaces/IRegionSerialiserModule.cs | 2 +- .../Scenes/Serialization/SceneObjectSerializer.cs | 61 +++--- .../Scenes/Serialization/SceneXmlLoader.cs | 212 ++++++++++++--------- 10 files changed, 188 insertions(+), 142 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 7a0142f..0c6f476 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -264,10 +264,11 @@ namespace OpenSim LoadOar); m_console.Commands.AddCommand("region", false, "save oar", - "save oar []", + "save oar [--old-guids] []", "Save a region's data to an OAR archive.", "The OAR path must be a filesystem path." - + " If this is not given then the oar is saved to region.oar in the current directory.", + + " If this is not given then the oar is saved to region.oar in the current directory." + Environment.NewLine + + "--old-guids produces OARs compatible with older (pre 0.7.1) OpenSim versions.", SaveOar); m_console.Commands.AddCommand("region", false, "edit scale", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 586d98e..eb9688d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected Scene m_scene; protected TarArchiveWriter m_archiveWriter; protected Guid m_requestId; + protected Dictionary m_options; public ArchiveWriteRequestExecution( List sceneObjects, @@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver IRegionSerialiserModule serialiser, Scene scene, TarArchiveWriter archiveWriter, - Guid requestId) + Guid requestId, + Dictionary options) { m_sceneObjects = sceneObjects; m_terrainModule = terrainModule; @@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene = scene; m_archiveWriter = archiveWriter; m_requestId = requestId; + m_options = options; } protected internal void ReceivedAllAssets( @@ -145,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); - string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); + string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, m_options); m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 283b33b..e9a476c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// Archive the region requested. /// /// if there was an io problem with creating the file - public void ArchiveRegion() + public void ArchiveRegion(Dictionary options) { Dictionary assetUuids = new Dictionary(); @@ -165,7 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.RequestModuleInterface(), m_scene, archiveWriter, - m_requestId); + m_requestId, + options); new AssetsRequest( new AssetsArchiver(archiveWriter), assetUuids, diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 82ede01..98bdcd0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -122,37 +122,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) { + Dictionary options = new Dictionary(); + + OptionSet ops = new OptionSet(); + ops.Add("old|old-guids", delegate(string v) { options["old-guids"] = (v != null); }); + + List mainParams = ops.Parse(cmdparams); + if (cmdparams.Length > 2) { - ArchiveRegion(cmdparams[2]); + ArchiveRegion(mainParams[2], options); } else { - ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); + ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options); } } - public void ArchiveRegion(string savePath) + public void ArchiveRegion(string savePath, Dictionary options) { - ArchiveRegion(savePath, Guid.Empty); + ArchiveRegion(savePath, Guid.Empty, options); } - - public void ArchiveRegion(string savePath, Guid requestId) + + public void ArchiveRegion(string savePath, Guid requestId, Dictionary options) { m_log.InfoFormat( "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); - new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(); + new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options); } - + public void ArchiveRegion(Stream saveStream) { ArchiveRegion(saveStream, Guid.Empty); } - + public void ArchiveRegion(Stream saveStream, Guid requestId) { - new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(); + new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary()); } public void DearchiveRegion(string loadPath) diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs index 04062b0..ec97acd 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs @@ -160,9 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); } - public string SerializeGroupToXml2(SceneObjectGroup grp) + public string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary options) { - return SceneXmlLoader.SaveGroupToXml2(grp); + return SceneXmlLoader.SaveGroupToXml2(grp, options); } public void SavePrimListToXml2(EntityBase[] entityList, string fileName) diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 799a448..49bd466 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests // Need to add the object to the scene so that the request to get script state succeeds m_scene.AddSceneObject(so); - string xml2 = m_serialiserModule.SerializeGroupToXml2(so); + string xml2 = m_serialiserModule.SerializeGroupToXml2(so, new System.Collections.Generic.Dictionary()); XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); xtr.ReadStartElement("SceneObjectGroup"); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 89e59d0..d8229de 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.IO; namespace OpenSim.Region.Framework.Interfaces @@ -46,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces /// the EventManager.OnOarFileSaved event. /// /// - void ArchiveRegion(string savePath); + void ArchiveRegion(string savePath, Dictionary options); /// /// Archive the region to the given path @@ -57,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// If supplied, this request Id is later returned in the saved event - void ArchiveRegion(string savePath, Guid requestId); + void ArchiveRegion(string savePath, Guid requestId, Dictionary options); /// /// Archive the region to a stream. diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs index 18758c8..c5b21a8 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs @@ -117,6 +117,6 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// - string SerializeGroupToXml2(SceneObjectGroup grp); + string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary options); } } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 6e3b15a..9a00bea 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1075,36 +1075,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization ////////// Write ///////// - public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog) + public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionaryoptions) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - SOPToXml2(writer, sog.RootPart, null); + SOPToXml2(writer, sog.RootPart, null, options); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); sog.ForEachPart(delegate(SceneObjectPart sop) { if (sop.UUID != sog.RootPart.UUID) - SOPToXml2(writer, sop, sog.RootPart); + SOPToXml2(writer, sop, sog.RootPart, options); }); writer.WriteEndElement(); writer.WriteEndElement(); } - static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent) + static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary options) { writer.WriteStartElement("SceneObjectPart"); writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower()); - WriteUUID(writer, "CreatorID", sop.CreatorID); - WriteUUID(writer, "FolderID", sop.FolderID); + WriteUUID(writer, "CreatorID", sop.CreatorID, options); + WriteUUID(writer, "FolderID", sop.FolderID, options); writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString()); - WriteTaskInventory(writer, sop.TaskInventory); + WriteTaskInventory(writer, sop.TaskInventory, options); - WriteUUID(writer, "UUID", sop.UUID); + WriteUUID(writer, "UUID", sop.UUID, options); writer.WriteElementString("LocalId", sop.LocalId.ToString()); writer.WriteElementString("Name", sop.Name); writer.WriteElementString("Material", sop.Material.ToString()); @@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); - WriteShape(writer, sop.Shape); + WriteShape(writer, sop.Shape, options); WriteVector(writer, "Scale", sop.Scale); writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString()); @@ -1151,16 +1151,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); - WriteUUID(writer, "GroupID", sop.GroupID); - WriteUUID(writer, "OwnerID", sop.OwnerID); - WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); + WriteUUID(writer, "GroupID", sop.GroupID, options); + WriteUUID(writer, "OwnerID", sop.OwnerID, options); + WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); writer.WriteElementString("Flags", sop.Flags.ToString()); - WriteUUID(writer, "CollisionSound", sop.CollisionSound); + WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); if (sop.MediaUrl != null) writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); @@ -1168,10 +1168,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); } - static void WriteUUID(XmlTextWriter writer, string name, UUID id) + static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary options) { writer.WriteStartElement(name); - writer.WriteElementString("UUID", id.ToString()); + if (options.ContainsKey("old-guids")) + writer.WriteElementString("Guid", id.ToString()); + else + writer.WriteElementString("UUID", id.ToString()); writer.WriteEndElement(); } @@ -1194,7 +1197,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); } - static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv) + static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary options) { if (tinv.Count > 0) // otherwise skip this { @@ -1203,27 +1206,27 @@ namespace OpenSim.Region.Framework.Scenes.Serialization foreach (TaskInventoryItem item in tinv.Values) { writer.WriteStartElement("TaskInventoryItem"); - - WriteUUID(writer, "AssetID", item.AssetID); + + WriteUUID(writer, "AssetID", item.AssetID, options); writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); writer.WriteElementString("CreationDate", item.CreationDate.ToString()); - WriteUUID(writer, "CreatorID", item.CreatorID); + WriteUUID(writer, "CreatorID", item.CreatorID, options); writer.WriteElementString("Description", item.Description); writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); writer.WriteElementString("Flags", item.Flags.ToString()); - WriteUUID(writer, "GroupID", item.GroupID); + WriteUUID(writer, "GroupID", item.GroupID, options); writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); writer.WriteElementString("InvType", item.InvType.ToString()); - WriteUUID(writer, "ItemID", item.ItemID); - WriteUUID(writer, "OldItemID", item.OldItemID); - WriteUUID(writer, "LastOwnerID", item.LastOwnerID); + WriteUUID(writer, "ItemID", item.ItemID, options); + WriteUUID(writer, "OldItemID", item.OldItemID, options); + WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options); writer.WriteElementString("Name", item.Name); writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); - WriteUUID(writer, "OwnerID", item.OwnerID); + WriteUUID(writer, "OwnerID", item.OwnerID, options); writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); - WriteUUID(writer, "ParentID", item.ParentID); - WriteUUID(writer, "ParentPartID", item.ParentPartID); - WriteUUID(writer, "PermsGranter", item.PermsGranter); + WriteUUID(writer, "ParentID", item.ParentID, options); + WriteUUID(writer, "ParentPartID", item.ParentPartID, options); + WriteUUID(writer, "PermsGranter", item.PermsGranter, options); writer.WriteElementString("PermsMask", item.PermsMask.ToString()); writer.WriteElementString("Type", item.Type.ToString()); @@ -1234,7 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } - static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp) + static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary options) { if (shp != null) { @@ -1283,7 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString()); writer.WriteElementString("HollowShape", shp.HollowShape.ToString()); - WriteUUID(writer, "SculptTexture", shp.SculptTexture); + WriteUUID(writer, "SculptTexture", shp.SculptTexture, options); writer.WriteElementString("SculptType", shp.SculptType.ToString()); writer.WriteStartElement("SculptData"); byte[] sd; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index c6d4e55..d214eba 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + #region old xml format public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) { XmlDocument doc = new XmlDocument(); @@ -98,11 +99,128 @@ namespace OpenSim.Region.Framework.Scenes.Serialization file.Close(); } - public static string SaveGroupToXml2(SceneObjectGroup grp) + #endregion + + #region XML2 serialization + + // Called by archives (save oar) + public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary options) + { + //return SceneObjectSerializer.ToXml2Format(grp); + using (MemoryStream mem = new MemoryStream()) + { + using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8)) + { + SceneObjectSerializer.SOGToXml2(writer, grp, options); + writer.Flush(); + + using (StreamReader reader = new StreamReader(mem)) + { + mem.Seek(0, SeekOrigin.Begin); + return reader.ReadToEnd(); + } + } + } + } + + // Called by scene serializer (save xml2) + public static void SavePrimsToXml2(Scene scene, string fileName) + { + EntityBase[] entityList = scene.GetEntities(); + SavePrimListToXml2(entityList, fileName); + } + + // Called by scene serializer (save xml2) + public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) + { + m_log.InfoFormat( + "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}", + primName, scene.RegionInfo.RegionName, fileName); + + EntityBase[] entityList = scene.GetEntities(); + List primList = new List(); + + foreach (EntityBase ent in entityList) + { + if (ent is SceneObjectGroup) + { + if (ent.Name == primName) + { + primList.Add(ent); + } + } + } + + SavePrimListToXml2(primList.ToArray(), fileName); + } + + // Called by REST Application plugin + public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max) + { + EntityBase[] entityList = scene.GetEntities(); + SavePrimListToXml2(entityList, stream, min, max); + } + + // Called here only. Should be private? + public static void SavePrimListToXml2(EntityBase[] entityList, string fileName) { - return SceneObjectSerializer.ToXml2Format(grp); + FileStream file = new FileStream(fileName, FileMode.Create); + try + { + StreamWriter stream = new StreamWriter(file); + try + { + SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero); + } + finally + { + stream.Close(); + } + } + finally + { + file.Close(); + } + } + + // Called here only. Should be private? + public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) + { + XmlTextWriter writer = new XmlTextWriter(stream); + + int primCount = 0; + stream.WriteLine("\n"); + + foreach (EntityBase ent in entityList) + { + if (ent is SceneObjectGroup) + { + SceneObjectGroup g = (SceneObjectGroup)ent; + if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero)) + { + Vector3 pos = g.RootPart.GetWorldPosition(); + if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z) + continue; + if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z) + continue; + } + + //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); + SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary()); + stream.WriteLine(); + + primCount++; + } + } + + stream.WriteLine("\n"); + stream.Flush(); } + #endregion + + #region XML2 deserialization + public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) { XmlDocument doc = new XmlDocument(); @@ -222,94 +340,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } - public static void SavePrimsToXml2(Scene scene, string fileName) - { - EntityBase[] entityList = scene.GetEntities(); - SavePrimListToXml2(entityList, fileName); - } - - public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max) - { - EntityBase[] entityList = scene.GetEntities(); - SavePrimListToXml2(entityList, stream, min, max); - } - - public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) - { - m_log.InfoFormat( - "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}", - primName, scene.RegionInfo.RegionName, fileName); - - EntityBase[] entityList = scene.GetEntities(); - List primList = new List(); - - foreach (EntityBase ent in entityList) - { - if (ent is SceneObjectGroup) - { - if (ent.Name == primName) - { - primList.Add(ent); - } - } - } - - SavePrimListToXml2(primList.ToArray(), fileName); - } - - public static void SavePrimListToXml2(EntityBase[] entityList, string fileName) - { - FileStream file = new FileStream(fileName, FileMode.Create); - try - { - StreamWriter stream = new StreamWriter(file); - try - { - SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero); - } - finally - { - stream.Close(); - } - } - finally - { - file.Close(); - } - } - - public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) - { - XmlTextWriter writer = new XmlTextWriter(stream); - - int primCount = 0; - stream.WriteLine("\n"); - - foreach (EntityBase ent in entityList) - { - if (ent is SceneObjectGroup) - { - SceneObjectGroup g = (SceneObjectGroup)ent; - if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero)) - { - Vector3 pos = g.RootPart.GetWorldPosition(); - if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z) - continue; - if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z) - continue; - } - - //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); - SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent); - stream.WriteLine(); - - primCount++; - } - } - - stream.WriteLine("\n"); - stream.Flush(); - } - + #endregion } } -- cgit v1.1 From fe4e6ff81121bd3c5041fc3cdc6545548b192568 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 02:38:46 +0100 Subject: Fix test break - TestSerializeXml2() still requires old-guids option --- .../Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 49bd466..bac7827 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using System.IO; +using System.Xml; using log4net.Config; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -34,8 +37,6 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Setup; -using System.IO; -using System.Xml; namespace OpenSim.Region.CoreModules.World.Serialiser.Tests { @@ -369,7 +370,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests // Need to add the object to the scene so that the request to get script state succeeds m_scene.AddSceneObject(so); - string xml2 = m_serialiserModule.SerializeGroupToXml2(so, new System.Collections.Generic.Dictionary()); + Dictionary options = new Dictionary(); + options["old-guids"] = true; + string xml2 = m_serialiserModule.SerializeGroupToXml2(so, options); XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); xtr.ReadStartElement("SceneObjectGroup"); -- cgit v1.1 From 1bd4219078b48e0e69aca65908a127bc19ca5610 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 03:52:11 +0100 Subject: save oar control file first rather than in the middle so that it's the first thing we come accross on load this exposes a weekness with using tar where we don't control the order in which files are loaded. can't be helped for now --- .../World/Archiver/ArchiveWriteRequestExecution.cs | 37 +-------------------- .../Archiver/ArchiveWriteRequestPreparation.cs | 38 ++++++++++++++++++++++ .../World/Archiver/Tests/ArchiverTests.cs | 4 +-- 3 files changed, 41 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index eb9688d..d1fe1f5 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -108,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver // "[ARCHIVER]: Received {0} of {1} assets requested", // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); - m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); - - // Write out control file - m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); - m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); - // Write out region settings string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); @@ -155,35 +149,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); } - /// - /// Create the control file for a 0.2 version archive - /// - /// - public static string Create0p2ControlFile() - { - StringWriter sw = new StringWriter(); - XmlTextWriter xtw = new XmlTextWriter(sw); - xtw.Formatting = Formatting.Indented; - xtw.WriteStartDocument(); - xtw.WriteStartElement("archive"); - xtw.WriteAttributeString("major_version", "0"); - xtw.WriteAttributeString("minor_version", "3"); - - xtw.WriteStartElement("creation_info"); - DateTime now = DateTime.UtcNow; - TimeSpan t = now - new DateTime(1970, 1, 1); - xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); - xtw.WriteElementString("id", UUID.Random().ToString()); - xtw.WriteEndElement(); - xtw.WriteEndElement(); - - xtw.Flush(); - xtw.Close(); - - String s = sw.ToString(); - sw.Close(); - - return s; - } + } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index e9a476c..f867e50 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -32,6 +32,7 @@ using System.IO.Compression; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; +using System.Xml; using log4net; using OpenMetaverse; using OpenSim.Framework; @@ -167,10 +168,47 @@ namespace OpenSim.Region.CoreModules.World.Archiver archiveWriter, m_requestId, options); + + m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); + + // Write out control file + archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); + m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); new AssetsRequest( new AssetsArchiver(archiveWriter), assetUuids, m_scene.AssetService, awre.ReceivedAllAssets).Execute(); } + + /// + /// Create the control file for a 0.2 version archive + /// + /// + public static string Create0p2ControlFile() + { + StringWriter sw = new StringWriter(); + XmlTextWriter xtw = new XmlTextWriter(sw); + xtw.Formatting = Formatting.Indented; + xtw.WriteStartDocument(); + xtw.WriteStartElement("archive"); + xtw.WriteAttributeString("major_version", "0"); + xtw.WriteAttributeString("minor_version", "3"); + + xtw.WriteStartElement("creation_info"); + DateTime now = DateTime.UtcNow; + TimeSpan t = now - new DateTime(1970, 1, 1); + xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); + xtw.WriteElementString("id", UUID.Random().ToString()); + xtw.WriteEndElement(); + xtw.WriteEndElement(); + + xtw.Flush(); + xtw.Close(); + + String s = sw.ToString(); + sw.Close(); + + return s; + } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 3342164..b72cd02 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests // upset load tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); + tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile()); SceneObjectPart part1 = CreateSceneObjectPart1(); SceneObjectGroup object1 = new SceneObjectGroup(part1); @@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); + tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile()); RegionSettings rs = new RegionSettings(); rs.AgentLimit = 17; -- cgit v1.1 From 3df8d8ff7601f8dd1bc818ed2a13946fd0d9a91e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 04:59:51 +0100 Subject: Have OpenSim throw a strop if it tries to load an OAR with a major version that is too high for it to handle --- .../World/Archiver/ArchiveReadRequest.cs | 22 ++++++++++++++++++++++ .../Archiver/ArchiveWriteRequestPreparation.cs | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 6b538f6..f1f5258 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -51,6 +51,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver public class ArchiveReadRequest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version + /// bumps here should be compatible. + /// + public static int MAX_MAJOR_VERSION = 0; protected Scene m_scene; protected Stream m_loadStream; @@ -497,6 +503,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver { if (xtr.NodeType == XmlNodeType.Element) { + if (xtr.Name.ToString() == "archive") + { + int majorVersion = int.Parse(xtr["major_version"]); + int minorVersion = int.Parse(xtr["minor_version"]); + string version = string.Format("{0}.{1}", majorVersion, minorVersion); + + if (majorVersion > MAX_MAJOR_VERSION) + { + throw new Exception( + string.Format( + "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below", + majorVersion, MAX_MAJOR_VERSION)); + } + + m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version); + } if (xtr.Name.ToString() == "datetime") { int value; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index f867e50..bae1bdd 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } /// - /// Create the control file for a 0.2 version archive + /// Create the control file for the most up to date archive /// /// public static string Create0p2ControlFile() -- cgit v1.1 From e41b23a1a4bef55d31f75e1227834da84cbd971a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 05:38:44 +0100 Subject: change --old-guids switch on the save oar command line to --version= if x is 0, then an old version 0.3 archive is saved. If it is anything else or missing, then a version 1.0 archive is saved version 1.0 archives cannot be loaded on OpenSim 0.7.0.2 and earlier also add various informational notices about what version we've saving/loading --- OpenSim/Region/Application/OpenSim.cs | 4 ++-- .../World/Archiver/ArchiveReadRequest.cs | 2 +- .../World/Archiver/ArchiveWriteRequestExecution.cs | 6 ++++- .../Archiver/ArchiveWriteRequestPreparation.cs | 26 ++++++++++++++++++---- .../CoreModules/World/Archiver/ArchiverModule.cs | 2 +- .../World/Archiver/Tests/ArchiverTests.cs | 4 ++-- 6 files changed, 33 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 0c6f476..66ffd76 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -264,11 +264,11 @@ namespace OpenSim LoadOar); m_console.Commands.AddCommand("region", false, "save oar", - "save oar [--old-guids] []", + "save oar [--version=] []", "Save a region's data to an OAR archive.", "The OAR path must be a filesystem path." + " If this is not given then the oar is saved to region.oar in the current directory." + Environment.NewLine - + "--old-guids produces OARs compatible with older (pre 0.7.1) OpenSim versions.", + + "--version=0 produces old version 0.3 OARs that are compatible with OpenSim 0.7.0.2 and earlier. Current OAR version is 1.0. This version of OpenSim can load any OAR later than version 0.3", SaveOar); m_console.Commands.AddCommand("region", false, "edit scale", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index f1f5258..ae6e596 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version /// bumps here should be compatible. /// - public static int MAX_MAJOR_VERSION = 0; + public static int MAX_MAJOR_VERSION = 1; protected Scene m_scene; protected Stream m_loadStream; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index d1fe1f5..79bec56 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -137,12 +137,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); + Dictionary serializationOptions = new Dictionary(); + if (m_options.ContainsKey("version") && (string)m_options["version"] == "0") + serializationOptions["old-guids"] = true; + // Write out scene object metadata foreach (SceneObjectGroup sceneObject in m_sceneObjects) { //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); - string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, m_options); + string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, serializationOptions); m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index bae1bdd..d21efed 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); // Write out control file - archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); + archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options)); m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); new AssetsRequest( @@ -184,15 +184,33 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// Create the control file for the most up to date archive /// /// - public static string Create0p2ControlFile() + public static string Create0p2ControlFile(Dictionary options) { + int majorVersion, minorVersion; + if (options.ContainsKey("version") && (string)options["version"] == "0") + { + majorVersion = 0; + minorVersion = 3; + } + else + { + majorVersion = 1; + minorVersion = 0; + } + + m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); + if (majorVersion == 1) + { + m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); + } + StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); xtw.WriteStartElement("archive"); - xtw.WriteAttributeString("major_version", "0"); - xtw.WriteAttributeString("minor_version", "3"); + xtw.WriteAttributeString("major_version", majorVersion.ToString()); + xtw.WriteAttributeString("minor_version", minorVersion.ToString()); xtw.WriteStartElement("creation_info"); DateTime now = DateTime.UtcNow; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 98bdcd0..e0ad71e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver Dictionary options = new Dictionary(); OptionSet ops = new OptionSet(); - ops.Add("old|old-guids", delegate(string v) { options["old-guids"] = (v != null); }); + ops.Add("v|version=", delegate(string v) { options["version"] = v; }); List mainParams = ops.Parse(cmdparams); diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index b72cd02..04bdc4f 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests // upset load tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile()); + tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary())); SceneObjectPart part1 = CreateSceneObjectPart1(); SceneObjectGroup object1 = new SceneObjectGroup(part1); @@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile()); + tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary())); RegionSettings rs = new RegionSettings(); rs.AgentLimit = 17; -- cgit v1.1 From edc31adf954276f00e272d1de9d162c3940ec62b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 07:09:13 +0100 Subject: Rip out version option since it turns out that the changed object serialization format can actually be loaded by older OpenSims after all This bumps the OAR version to 0.4 instead, signalling some change but with backwards compatability... for now. --- OpenSim/Region/Application/OpenSim.cs | 5 ++--- .../World/Archiver/ArchiveWriteRequestExecution.cs | 4 ++-- .../World/Archiver/ArchiveWriteRequestPreparation.cs | 14 +++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 66ffd76..7a0142f 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -264,11 +264,10 @@ namespace OpenSim LoadOar); m_console.Commands.AddCommand("region", false, "save oar", - "save oar [--version=] []", + "save oar []", "Save a region's data to an OAR archive.", "The OAR path must be a filesystem path." - + " If this is not given then the oar is saved to region.oar in the current directory." + Environment.NewLine - + "--version=0 produces old version 0.3 OARs that are compatible with OpenSim 0.7.0.2 and earlier. Current OAR version is 1.0. This version of OpenSim can load any OAR later than version 0.3", + + " If this is not given then the oar is saved to region.oar in the current directory.", SaveOar); m_console.Commands.AddCommand("region", false, "edit scale", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 79bec56..c062833 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -138,8 +138,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); Dictionary serializationOptions = new Dictionary(); - if (m_options.ContainsKey("version") && (string)m_options["version"] == "0") - serializationOptions["old-guids"] = true; +// if (m_options.ContainsKey("version") && (string)m_options["version"] == "0") +// serializationOptions["old-guids"] = true; // Write out scene object metadata foreach (SceneObjectGroup sceneObject in m_sceneObjects) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index d21efed..43789af 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -186,7 +186,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public static string Create0p2ControlFile(Dictionary options) { - int majorVersion, minorVersion; + int majorVersion = 0, minorVersion = 4; + + /* if (options.ContainsKey("version") && (string)options["version"] == "0") { majorVersion = 0; @@ -197,12 +199,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver majorVersion = 1; minorVersion = 0; } + */ m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); - if (majorVersion == 1) - { - m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); - } +// if (majorVersion == 1) +// { +// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); +// } + StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); -- cgit v1.1 From 06d37d06e6aa6eae313fb7bf186f3e0c7e66b115 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Oct 2010 07:25:55 +0100 Subject: Drop max oar loading version back to 0 from 1 --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index ae6e596..f1f5258 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version /// bumps here should be compatible. /// - public static int MAX_MAJOR_VERSION = 1; + public static int MAX_MAJOR_VERSION = 0; protected Scene m_scene; protected Stream m_loadStream; -- cgit v1.1 From 06b61b68c768b040894158199816bd11b0fd5f52 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 17 Oct 2010 01:47:07 -0400 Subject: Adding osFunctions for light projection Set the projection parameters in the host prim ... osSetProjectionParam(bool Enabled, key TextureMaskUUID, float FOV, float Focus, float Ambiance); Set the projection parameters in a target prim ... osSetProjectionParam(ikey target uuid, bool Enabled, key TextureMaskUUID, float FOV, float Focus, float Ambiance); Threat Level very high Signed-off-by: Melanie --- .../Shared/Api/Implementation/OSSL_Api.cs | 42 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 3 ++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++++ 3 files changed, 55 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 477c52d..8a98be7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2200,6 +2200,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_LSL_Api.SetPrimitiveParamsEx(prim, rules); } + + /// + /// Set parameters for light projection in host prim + /// + public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb) + { + CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams"); + + osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb); + } + + /// + /// Set parameters for light projection with uuid of target prim + /// + public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb) + { + CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams"); + m_host.AddScriptLPS(1); + + SceneObjectPart obj = null; + if (prim == UUID.Zero.ToString()) + { + obj = m_host; + } + else + { + obj = World.GetSceneObjectPart(new UUID(prim)); + if (obj == null) + return; + } + + obj.Shape.ProjectionEntry = projection; + obj.Shape.ProjectionTextureUUID = new UUID(texture); + obj.Shape.ProjectionFOV = (float)fov; + obj.Shape.ProjectionFocus = (float)focus; + obj.Shape.ProjectionAmbiance = (float)amb; + + + obj.ParentGroup.HasGroupChanged = true; + obj.ScheduleFullUpdate(); + + } /// /// Like osGetAgents but returns enough info for a radar diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 78ee43c..630821b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -176,6 +176,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osCauseDamage(string avatar, double damage); LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules); void osSetPrimitiveParams(LSL_Key prim, LSL_List rules); + void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb); + void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb); + LSL_List osGetAvatarList(); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6cc5f51..e289554 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -688,6 +688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osSetPrimitiveParams(prim, rules); } + public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb) + { + m_OSSL_Functions.osSetProjectionParams(projection, texture, fov, focus, amb); + } + + public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb) + { + m_OSSL_Functions.osSetProjectionParams(prim, projection, texture, fov, focus, amb); + } + public LSL_List osGetAvatarList() { return m_OSSL_Functions.osGetAvatarList(); -- cgit v1.1 From 22eff055d4c03d2bb0bd44f4259a280761d90715 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Oct 2010 10:35:38 -0700 Subject: .NET automagical serialization of SOPs replaced by manual serialization across the board. --- .../World/Serialiser/Tests/SerialiserTests.cs | 10 +++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 ++--- .../Scenes/Serialization/SceneObjectSerializer.cs | 65 +++++----------------- 3 files changed, 28 insertions(+), 62 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index bac7827..f10e848 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -303,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests { case "UUID": xtr.ReadStartElement("UUID"); - uuid = UUID.Parse(xtr.ReadElementString("Guid")); - xtr.ReadEndElement(); + try + { + uuid = UUID.Parse(xtr.ReadElementString("UUID")); + xtr.ReadEndElement(); + } + catch { } // ignore everything but ... break; case "Name": name = xtr.ReadElementContentAsString(); break; case "CreatorID": xtr.ReadStartElement("CreatorID"); - creatorId = UUID.Parse(xtr.ReadElementString("Guid")); + creatorId = UUID.Parse(xtr.ReadElementString("UUID")); xtr.ReadEndElement(); break; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 39b109b..bf4c55c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -39,6 +39,7 @@ using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Scripting; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Framework.Scenes @@ -124,10 +125,6 @@ namespace OpenSim.Region.Framework.Scenes get { return ParentGroup.RootPart == this; } } - // use only one serializer to give the runtime a chance to optimize it (it won't do that if you - // use a new instance every time) - private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); - #region Fields public bool AllowedDrop; @@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public static SceneObjectPart FromXml(XmlReader xmlReader) + public static SceneObjectPart FromXml(XmlTextReader xmlReader) { return FromXml(UUID.Zero, xmlReader); } @@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes /// The inventory id from which this part came, if applicable /// /// - public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) + public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader) { - SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); + SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader); part.m_fromUserInventoryItemID = fromUserInventoryItemId; // for tempOnRez objects, we have to fix the Expire date. @@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes /// Serialize this part to xml. /// /// - public void ToXml(XmlWriter xmlWriter) + public void ToXml(XmlTextWriter xmlWriter) { - serializer.Serialize(xmlWriter, this); + SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary()); } public void TriggerScriptChangedEvent(Changed val) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9a00bea..4897cd6 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -67,14 +67,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; - // libomv.types changes UUID to Guid - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - - // Handle Nested property - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - try { StringReader sr; @@ -126,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } + /// /// Serialize a scene object to the original xml format /// @@ -181,7 +174,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) { - part.ToXml(writer); + SOPToXml2(writer, part, new Dictionary()); } public static SceneObjectGroup FromXml2Format(string xmlData) @@ -189,14 +182,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; - // libomv.types changes UUID to Guid - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - - // Handle Nested property - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - try { XmlDocument doc = new XmlDocument(); @@ -261,41 +246,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { using (XmlTextWriter writer = new XmlTextWriter(sw)) { - ToXml2Format(sceneObject, writer); + SOGToXml2(writer, sceneObject, new Dictionary()); } return sw.ToString(); } } - /// - /// Serialize a scene object to the 'xml2' format. - /// - /// - /// - public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) - { - //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); - //int time = System.Environment.TickCount; - - writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - sceneObject.RootPart.ToXml(writer); - writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); - - SceneObjectPart[] parts = sceneObject.Parts; - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part.UUID != sceneObject.RootPart.UUID) - part.ToXml(writer); - } - - writer.WriteEndElement(); // End of OtherParts - sceneObject.SaveScriptedState(writer); - writer.WriteEndElement(); // End of SceneObjectGroup - - //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); - } #region manual serialization @@ -386,6 +343,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); + m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); + #endregion #region ShapeXmlProcessors initialization @@ -817,6 +776,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization item.Type = reader.ReadElementContentAsInt("Type", String.Empty); } + private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) + { + item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); + } + #endregion #region ShapeXmlProcessors @@ -1078,20 +1042,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionaryoptions) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - SOPToXml2(writer, sog.RootPart, null, options); + SOPToXml2(writer, sog.RootPart, options); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); sog.ForEachPart(delegate(SceneObjectPart sop) { if (sop.UUID != sog.RootPart.UUID) - SOPToXml2(writer, sop, sog.RootPart, options); + SOPToXml2(writer, sop, options); }); writer.WriteEndElement(); writer.WriteEndElement(); } - static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary options) + public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary options) { writer.WriteStartElement("SceneObjectPart"); writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); @@ -1229,6 +1193,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "PermsGranter", item.PermsGranter, options); writer.WriteElementString("PermsMask", item.PermsMask.ToString()); writer.WriteElementString("Type", item.Type.ToString()); + writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); writer.WriteEndElement(); // TaskInventoryItem } @@ -1398,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } else { - //m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); + m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); reader.ReadOuterXml(); // ignore } -- cgit v1.1 From 7038f2b40634a3f17259be52ff67a887e003cb05 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Oct 2010 10:41:38 -0700 Subject: Deleted all [XmlIgnore] from SOP, since those are meaningless now. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 110 ++++++++++----------- .../Scenes/Serialization/SceneObjectSerializer.cs | 6 +- 2 files changed, 58 insertions(+), 58 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bf4c55c..7a6449d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -119,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Is this sop a root part? /// - [XmlIgnore] + public bool IsRoot { get { return ParentGroup.RootPart == this; } @@ -129,26 +129,26 @@ namespace OpenSim.Region.Framework.Scenes public bool AllowedDrop; - [XmlIgnore] + public bool DIE_AT_EDGE; - [XmlIgnore] + public bool RETURN_AT_EDGE; - [XmlIgnore] + public bool BlockGrab; - [XmlIgnore] + public bool StatusSandbox; - [XmlIgnore] + public Vector3 StatusSandboxPos; // TODO: This needs to be persisted in next XML version update! - [XmlIgnore] + public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; - [XmlIgnore] + public PhysicsActor PhysActor { get { return m_physActor; } @@ -163,43 +163,43 @@ namespace OpenSim.Region.Framework.Scenes // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. // Not a big problem as long as the script that sets it remains in the prim on startup. // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script) - [XmlIgnore] + public UUID Sound; - [XmlIgnore] + public byte SoundFlags; - [XmlIgnore] + public double SoundGain; - [XmlIgnore] + public double SoundRadius; - [XmlIgnore] + public uint TimeStampFull; - [XmlIgnore] + public uint TimeStampLastActivity; // Will be used for AutoReturn - [XmlIgnore] + public uint TimeStampTerse; - [XmlIgnore] + public UUID FromItemID; - [XmlIgnore] + public UUID FromFolderID; - [XmlIgnore] + public int STATUS_ROTATE_X; - [XmlIgnore] + public int STATUS_ROTATE_Y; - [XmlIgnore] + public int STATUS_ROTATE_Z; - [XmlIgnore] + private Dictionary m_CollisionFilter = new Dictionary(); /// @@ -208,68 +208,68 @@ namespace OpenSim.Region.Framework.Scenes /// private UUID m_fromUserInventoryItemID; - [XmlIgnore] + public UUID FromUserInventoryItemID { get { return m_fromUserInventoryItemID; } } - [XmlIgnore] + public bool IsAttachment; - [XmlIgnore] + public scriptEvents AggregateScriptEvents; - [XmlIgnore] + public UUID AttachedAvatar; - [XmlIgnore] + public Vector3 AttachedPos; - [XmlIgnore] + public uint AttachmentPoint; - [XmlIgnore] + public Vector3 RotationAxis = Vector3.One; - [XmlIgnore] + public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this // Certainly this must be a persistant setting finally - [XmlIgnore] + public bool IsWaitingForFirstSpinUpdatePacket; - [XmlIgnore] + public Quaternion SpinOldOrientation = Quaternion.Identity; - [XmlIgnore] + public Quaternion m_APIDTarget = Quaternion.Identity; - [XmlIgnore] + public float m_APIDDamp = 0; - [XmlIgnore] + public float m_APIDStrength = 0; /// /// This part's inventory /// - [XmlIgnore] + public IEntityInventory Inventory { get { return m_inventory; } } protected SceneObjectPartInventory m_inventory; - [XmlIgnore] + public bool Undoing; - [XmlIgnore] + public bool IgnoreUndoUpdate = false; - [XmlIgnore] + private PrimFlags LocalFlags; - [XmlIgnore] + private float m_damage = -1.0f; private byte[] m_TextureAnimation; private byte m_clickAction; @@ -277,9 +277,9 @@ namespace OpenSim.Region.Framework.Scenes private string m_description = String.Empty; private readonly List m_lastColliders = new List(); private int m_linkNum; - [XmlIgnore] + private int m_scriptAccessPin; - [XmlIgnore] + private readonly Dictionary m_scriptEvents = new Dictionary(); private string m_sitName = String.Empty; private Quaternion m_sitTargetOrientation = Quaternion.Identity; @@ -545,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes } - [XmlIgnore] + public Dictionary CollisionFilter { get { return m_CollisionFilter; } @@ -555,21 +555,21 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public Quaternion APIDTarget { get { return m_APIDTarget; } set { m_APIDTarget = value; } } - [XmlIgnore] + public float APIDDamp { get { return m_APIDDamp; } set { m_APIDDamp = value; } } - [XmlIgnore] + public float APIDStrength { get { return m_APIDStrength; } @@ -615,35 +615,35 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundSlavePrims = value; } } - [XmlIgnore] + public Byte[] TextureAnimation { get { return m_TextureAnimation; } set { m_TextureAnimation = value; } } - [XmlIgnore] + public Byte[] ParticleSystem { get { return m_particleSystem; } set { m_particleSystem = value; } } - [XmlIgnore] + public DateTime Expires { get { return m_expires; } set { m_expires = value; } } - [XmlIgnore] + public DateTime Rezzed { get { return m_rezzed; } set { m_rezzed = value; } } - [XmlIgnore] + public float Damage { get { return m_damage; } @@ -1016,7 +1016,7 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public bool CreateSelected { get { return m_createSelected; } @@ -1198,14 +1198,14 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public UUID SitTargetAvatar { get { return m_sitTargetAvatar; } set { m_sitTargetAvatar = value; } } - [XmlIgnore] + public virtual UUID RegionID { get @@ -1219,7 +1219,7 @@ namespace OpenSim.Region.Framework.Scenes } private UUID _parentUUID = UUID.Zero; - [XmlIgnore] + public UUID ParentUUID { get @@ -1233,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes set { _parentUUID = value; } } - [XmlIgnore] + public string SitAnimation { get { return m_sitAnimation; } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 4897cd6..252304b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -149,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); writer.WriteStartElement(String.Empty, "RootPart", String.Empty); - ToOriginalXmlFormat(sceneObject.RootPart, writer); + ToXmlFormat(sceneObject.RootPart, writer); writer.WriteEndElement(); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); @@ -160,7 +160,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (part.UUID != sceneObject.RootPart.UUID) { writer.WriteStartElement(String.Empty, "Part", String.Empty); - ToOriginalXmlFormat(part, writer); + ToXmlFormat(part, writer); writer.WriteEndElement(); } } @@ -172,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); } - protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) + protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) { SOPToXml2(writer, part, new Dictionary()); } -- cgit v1.1