From 3fbf2ef6aac50571de0148cff2342e10b60de229 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 22 Apr 2007 14:14:32 +0000 Subject: [PATCH] XML importing and exporting should be functional again git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1137 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/LLObject.cs | 14 ++-- libsecondlife/ObjectManager.cs | 74 +++++++++++++------ libsecondlife/Prims.cs | 21 +----- libsecondlife/Types.cs | 45 +++++++---- .../TestClient/Commands/ExportCommand.cs | 25 ++++--- .../TestClient/Commands/ImportCommand.cs | 11 ++- 6 files changed, 110 insertions(+), 80 deletions(-) diff --git a/libsecondlife/LLObject.cs b/libsecondlife/LLObject.cs index b1ee8476..e421eaf0 100644 --- a/libsecondlife/LLObject.cs +++ b/libsecondlife/LLObject.cs @@ -232,6 +232,8 @@ namespace libsecondlife /// public enum RequestFlagsType { + /// + None = 0, /// BugReportRequest = 1, /// @@ -310,22 +312,16 @@ namespace libsecondlife /// public ObjectProperties Properties; /// + [XmlIgnore] public ObjectPropertiesFamily PropertiesFamily; /// public NameValue[] NameValues; + /// + public ObjectData Data; #endregion Public Members - #region Public Properties - - /// - public ObjectData Data { get { return data; } } - - #endregion Public Properties - - - internal ObjectData data; //internal DateTime lastInterpolation; diff --git a/libsecondlife/ObjectManager.cs b/libsecondlife/ObjectManager.cs index e1bc30aa..8ac38b19 100644 --- a/libsecondlife/ObjectManager.cs +++ b/libsecondlife/ObjectManager.cs @@ -619,6 +619,30 @@ namespace libsecondlife Client.Network.SendPacket(select, simulator); } + /// + /// Select multiple objects. This will trigger the simulator to send us + /// back ObjectProperties for each object + /// + /// + /// + public void SelectObjects(Simulator simulator, uint[] localIDs) + { + ObjectSelectPacket select = new ObjectSelectPacket(); + + select.AgentData.AgentID = Client.Network.AgentID; + select.AgentData.SessionID = Client.Network.SessionID; + + select.ObjectData = new ObjectSelectPacket.ObjectDataBlock[localIDs.Length]; + + for (int i = 0; i < localIDs.Length; i++) + { + select.ObjectData[i] = new ObjectSelectPacket.ObjectDataBlock(); + select.ObjectData[i].ObjectLocalID = localIDs[i]; + } + + Client.Network.SendPacket(select, simulator); + } + /// /// /// @@ -1213,6 +1237,7 @@ namespace libsecondlife data.ProfileBegin = LLObject.ProfileBeginFloat(block.ProfileBegin); data.ProfileEnd = LLObject.ProfileEndFloat(block.ProfileEnd); data.ProfileHollow = block.ProfileHollow; + data.PCode = pcode; #endregion #region Decode Additional packed parameters in ObjectData @@ -1375,7 +1400,7 @@ namespace libsecondlife prim.JointAxisOrAnchor = block.JointAxisOrAnchor; // Object parameters - prim.data = data; + prim.Data = data; // Textures, texture animations, particle system, and extra params prim.Textures = new Primitive.TextureEntry(block.TextureEntry, 0, @@ -1455,7 +1480,7 @@ namespace libsecondlife avatar.Rotation = rotation; avatar.AngularVelocity = angularVelocity; avatar.NameValues = nameValues; - avatar.data = data; + avatar.Data = data; avatar.GenericData = block.Data; SetAvatarSittingOn(avatar, block.ParentID); @@ -1685,6 +1710,7 @@ namespace libsecondlife prim.LocalID = LocalID; prim.ID = FullID; prim.Flags = (LLObject.ObjectFlags)block.UpdateFlags; + prim.Data.PCode = pcode; switch (pcode) { @@ -1694,11 +1720,11 @@ namespace libsecondlife #region Foliage Decoding // State - prim.data.State = (uint)block.Data[i++]; + prim.Data.State = (uint)block.Data[i++]; // CRC i += 4; // Material - prim.data.Material = (uint)block.Data[i++]; + prim.Data.Material = (uint)block.Data[i++]; // Click action prim.ClickAction = (ClickAction)block.Data[i++]; // Scale @@ -1723,11 +1749,11 @@ namespace libsecondlife case PCode.Prim: #region Decode block and update Prim // State - prim.data.State = (uint)block.Data[i++]; + prim.Data.State = (uint)block.Data[i++]; // CRC i += 4; // Material - prim.data.Material = (uint)block.Data[i++]; + prim.Data.Material = (uint)block.Data[i++]; // Click action prim.ClickAction = (ClickAction)block.Data[i++]; // Scale @@ -1872,25 +1898,25 @@ namespace libsecondlife } } - prim.data.PathCurve = (uint)block.Data[i++]; - prim.data.PathBegin = LLObject.PathBeginFloat(block.Data[i++]); - prim.data.PathEnd = LLObject.PathEndFloat(block.Data[i++]); - prim.data.PathScaleX = LLObject.PathScaleFloat(block.Data[i++]); - prim.data.PathScaleY = LLObject.PathScaleFloat(block.Data[i++]); - prim.data.PathShearX = LLObject.PathShearFloat(block.Data[i++]); - prim.data.PathShearY = LLObject.PathShearFloat(block.Data[i++]); - prim.data.PathTwist = (int)block.Data[i++]; - prim.data.PathTwistBegin = (int)block.Data[i++]; - prim.data.PathRadiusOffset = LLObject.PathRadiusOffsetFloat((sbyte)block.Data[i++]); - prim.data.PathTaperX = LLObject.PathTaperFloat((sbyte)block.Data[i++]); - prim.data.PathTaperY = LLObject.PathTaperFloat((sbyte)block.Data[i++]); - prim.data.PathRevolutions = LLObject.PathRevolutionsFloat(block.Data[i++]); - prim.data.PathSkew = LLObject.PathSkewFloat((sbyte)block.Data[i++]); + prim.Data.PathCurve = (uint)block.Data[i++]; + prim.Data.PathBegin = LLObject.PathBeginFloat(block.Data[i++]); + prim.Data.PathEnd = LLObject.PathEndFloat(block.Data[i++]); + prim.Data.PathScaleX = LLObject.PathScaleFloat(block.Data[i++]); + prim.Data.PathScaleY = LLObject.PathScaleFloat(block.Data[i++]); + prim.Data.PathShearX = LLObject.PathShearFloat(block.Data[i++]); + prim.Data.PathShearY = LLObject.PathShearFloat(block.Data[i++]); + prim.Data.PathTwist = (int)block.Data[i++]; + prim.Data.PathTwistBegin = (int)block.Data[i++]; + prim.Data.PathRadiusOffset = LLObject.PathRadiusOffsetFloat((sbyte)block.Data[i++]); + prim.Data.PathTaperX = LLObject.PathTaperFloat((sbyte)block.Data[i++]); + prim.Data.PathTaperY = LLObject.PathTaperFloat((sbyte)block.Data[i++]); + prim.Data.PathRevolutions = LLObject.PathRevolutionsFloat(block.Data[i++]); + prim.Data.PathSkew = LLObject.PathSkewFloat((sbyte)block.Data[i++]); - prim.data.ProfileCurve = (uint)block.Data[i++]; - prim.data.ProfileBegin = Primitive.ProfileBeginFloat(block.Data[i++]); - prim.data.ProfileEnd = Primitive.ProfileEndFloat(block.Data[i++]); - prim.data.ProfileHollow = (uint)block.Data[i++]; + prim.Data.ProfileCurve = (uint)block.Data[i++]; + prim.Data.ProfileBegin = Primitive.ProfileBeginFloat(block.Data[i++]); + prim.Data.ProfileEnd = Primitive.ProfileEndFloat(block.Data[i++]); + prim.Data.ProfileHollow = (uint)block.Data[i++]; // TextureEntry int textureEntryLength = (int)(block.Data[i++] + (block.Data[i++] << 8) + diff --git a/libsecondlife/Prims.cs b/libsecondlife/Prims.cs index 1e1ba0ae..1879153e 100644 --- a/libsecondlife/Prims.cs +++ b/libsecondlife/Prims.cs @@ -41,10 +41,8 @@ namespace libsecondlife public enum ExtraParamType : ushort { /// Whether this object has flexible parameters - [XmlEnum("Flexible")] Flexible = 0x10, /// Whether this object has light parameters - [XmlEnum("Light")] Light = 0x20 } @@ -77,19 +75,14 @@ namespace libsecondlife public class FlexibleData { /// - [XmlAttribute("softness"), DefaultValue(0)] public int Softness; /// - [XmlAttribute("gravity"), DefaultValue(0)] public float Gravity; /// - [XmlAttribute("drag"), DefaultValue(0)] public float Drag; /// - [XmlAttribute("wind"), DefaultValue(0)] public float Wind; /// - [XmlAttribute("tension"), DefaultValue(0)] public float Tension; /// public LLVector3 Force = LLVector3.Zero; @@ -154,22 +147,16 @@ namespace libsecondlife public class LightData { /// - [XmlAttribute("red"), DefaultValue(0)] public byte R; /// - [XmlAttribute("green"), DefaultValue(0)] public byte G; /// - [XmlAttribute("blue"), DefaultValue(0)] public byte B; /// - [XmlAttribute("intensity"), DefaultValue(0)] public float Intensity; /// - [XmlAttribute("radius"), DefaultValue(0)] public float Radius; /// - [XmlAttribute("falloff"), DefaultValue(0)] public float Falloff; /// @@ -285,16 +272,16 @@ namespace libsecondlife public override string ToString() { - string output = ""; + string output = String.Empty; output += "ID: " + ID + ", "; output += "GroupID: " + GroupID + ", "; output += "ParentID: " + ParentID + ", "; output += "LocalID: " + LocalID + ", "; output += "Flags: " + Flags + ", "; - output += "State: " + data.State + ", "; - output += "PCode: " + data.PCode + ", "; - output += "Material: " + data.Material + ", "; + output += "State: " + Data.State + ", "; + output += "PCode: " + Data.PCode + ", "; + output += "Material: " + Data.Material + ", "; return output; } diff --git a/libsecondlife/Types.cs b/libsecondlife/Types.cs index deadb6a0..0d8d3775 100644 --- a/libsecondlife/Types.cs +++ b/libsecondlife/Types.cs @@ -39,6 +39,7 @@ namespace libsecondlife public struct LLUUID { /// The System.Guid object this struct wraps around + [XmlAttribute] public Guid UUID; /// Get a byte array of the 16 raw bytes making up the UUID @@ -310,10 +311,13 @@ namespace libsecondlife public struct LLVector3 { /// X value + [XmlAttribute] public float X; /// Y value + [XmlAttribute] public float Y; /// Z value + [XmlAttribute] public float Z; /// @@ -565,11 +569,14 @@ namespace libsecondlife public struct LLVector3d { /// X value - [XmlAttribute("x"), DefaultValue(0)] public double X; + [XmlAttribute] + public double X; /// Y value - [XmlAttribute("y"), DefaultValue(0)] public double Y; + [XmlAttribute] + public double Y; /// Z value - [XmlAttribute("z"), DefaultValue(0)] public double Z; + [XmlAttribute] + public double Z; /// /// @@ -734,13 +741,17 @@ namespace libsecondlife public struct LLVector4 { /// - [XmlAttribute("x"), DefaultValue(0)] public float X; + [XmlAttribute] + public float X; /// - [XmlAttribute("y"), DefaultValue(0)] public float Y; + [XmlAttribute] + public float Y; /// - [XmlAttribute("z"), DefaultValue(0)] public float Z; + [XmlAttribute] + public float Z; /// - [XmlAttribute("s"), DefaultValue(0)] public float S; + [XmlAttribute] + public float S; /// /// @@ -819,16 +830,16 @@ namespace libsecondlife public struct LLColor { /// Red - [XmlAttribute("r"), DefaultValue(0)] + [XmlAttribute] public float R; /// Green - [XmlAttribute("g"), DefaultValue(0)] + [XmlAttribute] public float G; /// Blue - [XmlAttribute("b"), DefaultValue(0)] + [XmlAttribute] public float B; /// Alpha - [XmlAttribute("a"), DefaultValue(0)] + [XmlAttribute] public float A; /// @@ -910,13 +921,17 @@ namespace libsecondlife public struct LLQuaternion { /// X value - [XmlAttribute("x"), DefaultValue(0)] public float X; + [XmlAttribute] + public float X; /// Y value - [XmlAttribute("y"), DefaultValue(0)] public float Y; + [XmlAttribute] + public float Y; /// Z value - [XmlAttribute("z"), DefaultValue(0)] public float Z; + [XmlAttribute] + public float Z; /// W value - [XmlAttribute("w"), DefaultValue(0)] public float W; + [XmlAttribute] + public float W; /// /// Build a quaternion object from a byte array diff --git a/libsecondlife/examples/TestClient/Commands/ExportCommand.cs b/libsecondlife/examples/TestClient/Commands/ExportCommand.cs index 7baeea8d..95b13423 100644 --- a/libsecondlife/examples/TestClient/Commands/ExportCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/ExportCommand.cs @@ -72,12 +72,12 @@ namespace libsecondlife.TestClient { return "Couldn't fetch permissions for the requested object, try again"; } - else + else { GotPermissions = false; - if (Properties.OwnerID != Client.Network.AgentID) + if (Properties.OwnerID != Client.Network.AgentID && Client.Network.AgentID != Client.Self.ID) { - // We need a MasterID field, those exports should be allowed as well + // FIXME: We need a MasterID field, those exports should be allowed as well return "That object is owned by " + Properties.OwnerID + ", we don't have permission " + "to export it"; } @@ -107,7 +107,7 @@ namespace libsecondlife.TestClient } } } - bool complete = RequestObjectProperties(prims, (int)TimeSpan.FromMinutes(1).TotalMilliseconds); + bool complete = RequestObjectProperties(prims, 250); //Serialize it! Helpers.PrimListToXml(prims, writer); @@ -144,22 +144,23 @@ namespace libsecondlife.TestClient private bool RequestObjectProperties(List objects, int msPerRequest) { + // Create an array of the local IDs of all the prims we are requesting properties for + uint[] localids = new uint[objects.Count]; + lock (PrimsWaiting) { PrimsWaiting.Clear(); - ObjectSelectPacket select = new ObjectSelectPacket(); - select.ObjectData = new ObjectSelectPacket.ObjectDataBlock[objects.Count]; + for (int i = 0; i < objects.Count; ++i) { - select.ObjectData[i] = new ObjectSelectPacket.ObjectDataBlock(); - select.ObjectData[i].ObjectLocalID = objects[i].LocalID; + localids[i] = objects[i].LocalID; PrimsWaiting.Add(objects[i].ID, objects[i]); } - select.AgentData.AgentID = Client.Self.ID; - select.AgentData.SessionID = Client.Network.SessionID; - Client.Network.SendPacket(select); // this should cause the server to send us ObjectProperty packets } - return AllPropertiesReceived.WaitOne(msPerRequest * objects.Count, false); + + Client.Objects.SelectObjects(Client.Network.CurrentSim, localids); + + return AllPropertiesReceived.WaitOne(3000 + msPerRequest * objects.Count, false); } void Objects_OnObjectPropertiesFamily(Simulator simulator, LLObject.ObjectPropertiesFamily properties) diff --git a/libsecondlife/examples/TestClient/Commands/ImportCommand.cs b/libsecondlife/examples/TestClient/Commands/ImportCommand.cs index 66f0c7b1..5f8723a1 100644 --- a/libsecondlife/examples/TestClient/Commands/ImportCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/ImportCommand.cs @@ -48,7 +48,7 @@ namespace libsecondlife.TestClient public ImportCommand(TestClient testClient) { Name = "import"; - Description = "Import prims from an exported xml file. Usage: import [filename.xml]"; + Description = "Import prims from an exported xml file. Usage: import inputfile.xml"; primDone = new AutoResetEvent(false); registeredCreateEvent = false; } @@ -217,8 +217,13 @@ namespace libsecondlife.TestClient currentClient.Objects.SetTextures(simulator, prim.LocalID, currentPrim.Textures); currentClient.Objects.SetLight(simulator, prim.LocalID, currentPrim.Light); currentClient.Objects.SetFlexible(simulator, prim.LocalID, currentPrim.Flexible); - currentClient.Objects.SetName(simulator, prim.LocalID, currentPrim.Properties.Name); - currentClient.Objects.SetDescription(simulator, prim.LocalID, currentPrim.Properties.Description); + + if (!String.IsNullOrEmpty(currentPrim.Properties.Name)) + currentClient.Objects.SetName(simulator, prim.LocalID, currentPrim.Properties.Name); + if (!String.IsNullOrEmpty(currentPrim.Properties.Description)) + currentClient.Objects.SetDescription(simulator, prim.LocalID, + currentPrim.Properties.Description); + primsCreated.Add(prim); primDone.Set(); }