diff --git a/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs b/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs index 5e98e5c4..c210eb0e 100644 --- a/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs +++ b/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs @@ -61,7 +61,7 @@ namespace OpenMetaverse.Rendering return mesh; } - public void TransformTexCoords(List vertices, Vector3 center, LLObject.TextureEntryFace teFace) + public void TransformTexCoords(List vertices, Vector3 center, Primitive.TextureEntryFace teFace) { // Lalala... } @@ -132,7 +132,7 @@ namespace OpenMetaverse.Rendering return new List(indices); } - private List GenerateFaces(LLObject.TextureEntry te) + private List GenerateFaces(Primitive.TextureEntry te) { Face face = new Face(); face.Edge = new List(); diff --git a/OpenMetaverse.Tests/PrimObjectTests.cs b/OpenMetaverse.Tests/PrimObjectTests.cs index c595d0c6..b3611d6c 100644 --- a/OpenMetaverse.Tests/PrimObjectTests.cs +++ b/OpenMetaverse.Tests/PrimObjectTests.cs @@ -41,8 +41,8 @@ namespace OpenMetaverse.Tests { for (byte i = 0; i < byte.MaxValue; i++) { - float floatValue = LLObject.UnpackBeginCut(i); - ushort result = LLObject.PackBeginCut(floatValue); + float floatValue = Primitive.UnpackBeginCut(i); + ushort result = Primitive.PackBeginCut(floatValue); Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + ", and ended up with " + result); @@ -54,8 +54,8 @@ namespace OpenMetaverse.Tests { for (byte i = 0; i < byte.MaxValue; i++) { - float floatValue = LLObject.UnpackEndCut(i); - ushort result = LLObject.PackEndCut(floatValue); + float floatValue = Primitive.UnpackEndCut(i); + ushort result = Primitive.PackEndCut(floatValue); Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + ", and ended up with " + result); @@ -67,8 +67,8 @@ namespace OpenMetaverse.Tests { for (byte i = 0; i < byte.MaxValue; i++) { - float floatValue = LLObject.UnpackPathRevolutions(i); - byte result = LLObject.PackPathRevolutions(floatValue); + float floatValue = Primitive.UnpackPathRevolutions(i); + byte result = Primitive.PackPathRevolutions(floatValue); Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + ", and ended up with " + result); @@ -80,8 +80,8 @@ namespace OpenMetaverse.Tests { for (byte i = 0; i < byte.MaxValue; i++) { - float floatValue = LLObject.UnpackPathScale(i); - byte result = LLObject.PackPathScale(floatValue); + float floatValue = Primitive.UnpackPathScale(i); + byte result = Primitive.PackPathScale(floatValue); Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + ", and ended up with " + result); @@ -93,8 +93,8 @@ namespace OpenMetaverse.Tests //{ // for (byte i = 0; i < byte.MaxValue; i++) // { - // float floatValue = LLObject.UnpackPathShear(i); - // byte result = LLObject.PackPathShear(floatValue); + // float floatValue = Primitive.UnpackPathShear(i); + // byte result = Primitive.PackPathShear(floatValue); // Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + // ", and ended up with " + result); @@ -106,8 +106,8 @@ namespace OpenMetaverse.Tests { for (sbyte i = sbyte.MinValue; i < sbyte.MaxValue; i++) { - float floatValue = LLObject.UnpackPathTaper(i); - sbyte result = LLObject.PackPathTaper(floatValue); + float floatValue = Primitive.UnpackPathTaper(i); + sbyte result = Primitive.PackPathTaper(floatValue); Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue + ", and ended up with " + result); @@ -132,8 +132,8 @@ namespace OpenMetaverse.Tests [Test] public void TextureEntry() { - LLObject.TextureEntry te = new LLObject.TextureEntry(UUID.Random()); - LLObject.TextureEntryFace face = te.CreateFace(0); + Primitive.TextureEntry te = new Primitive.TextureEntry(UUID.Random()); + Primitive.TextureEntryFace face = te.CreateFace(0); face.Bump = Bumpiness.Concrete; face.Fullbright = true; face.MediaFlags = true; @@ -149,7 +149,7 @@ namespace OpenMetaverse.Tests byte[] teBytes = te.ToBytes(); - LLObject.TextureEntry te2 = new LLObject.TextureEntry(teBytes, 0, teBytes.Length); + Primitive.TextureEntry te2 = new Primitive.TextureEntry(teBytes, 0, teBytes.Length); byte[] teBytes2 = te2.ToBytes(); diff --git a/OpenMetaverse/AppearanceManager.cs b/OpenMetaverse/AppearanceManager.cs index 53cf2327..18c53556 100644 --- a/OpenMetaverse/AppearanceManager.cs +++ b/OpenMetaverse/AppearanceManager.cs @@ -100,7 +100,7 @@ namespace OpenMetaverse /// /// /// - public delegate void AppearanceUpdatedCallback(LLObject.TextureEntry te); + public delegate void AppearanceUpdatedCallback(Primitive.TextureEntry te); /// public event AgentWearablesCallback OnAgentWearables; @@ -639,7 +639,7 @@ namespace OpenMetaverse #region Send Appearance - LLObject.TextureEntry te = null; + Primitive.TextureEntry te = null; ObjectManager.NewAvatarCallback updateCallback = delegate(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation) @@ -652,7 +652,7 @@ namespace OpenMetaverse for (uint i = 0; i < AgentTextures.Length; i++) { - LLObject.TextureEntryFace face = avatar.Textures.FaceTextures[i]; + Primitive.TextureEntryFace face = avatar.Textures.FaceTextures[i]; if (face == null) { @@ -888,7 +888,7 @@ namespace OpenMetaverse } // Build the texture entry for our agent - LLObject.TextureEntry te = new LLObject.TextureEntry(DEFAULT_AVATAR_TEXTURE); + Primitive.TextureEntry te = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE); // Put our AgentTextures array in to TextureEntry lock (AgentTextures) @@ -897,7 +897,7 @@ namespace OpenMetaverse { if (AgentTextures[i] != UUID.Zero) { - LLObject.TextureEntryFace face = te.CreateFace(i); + Primitive.TextureEntryFace face = te.CreateFace(i); face.TextureID = AgentTextures[i]; } } @@ -909,7 +909,7 @@ namespace OpenMetaverse { foreach (KeyValuePair texture in data.Asset.Textures) { - LLObject.TextureEntryFace face = te.CreateFace((uint)texture.Key); + Primitive.TextureEntryFace face = te.CreateFace((uint)texture.Key); face.TextureID = texture.Value; Logger.DebugLog("Setting agent texture " + ((TextureIndex)texture.Key).ToString() + " to " + diff --git a/OpenMetaverse/Avatar.cs b/OpenMetaverse/Avatar.cs index 8072943b..24757a66 100644 --- a/OpenMetaverse/Avatar.cs +++ b/OpenMetaverse/Avatar.cs @@ -35,22 +35,26 @@ namespace OpenMetaverse /// /// Represents an avatar (other than your own) /// - public class Avatar : LLObject + public class Avatar : Primitive { + #region Enums + /// /// Avatar profile flags /// [Flags] public enum ProfileFlags { - ALLOW_PUBLISH = 1, - MATURE_PUBLISH = 2, - IDENTIFIED = 4, - TRANSACTED = 8, - ONLINE = 16 + AllowPublish = 1, + MaturePublish = 2, + Identified = 4, + Transacted = 8, + Online = 16 } - #region Avatar Structs + #endregion Enums + + #region Subclasses /// /// Positive and negative ratings @@ -105,96 +109,61 @@ namespace OpenMetaverse /// Should this profile be published on the web public bool AllowPublish { - get - { - return ((Flags & ProfileFlags.ALLOW_PUBLISH) != 0); - } + get { return ((Flags & ProfileFlags.AllowPublish) != 0); } set { if (value == true) - { - Flags |= ProfileFlags.ALLOW_PUBLISH; - } + Flags |= ProfileFlags.AllowPublish; else - { - Flags &= ~ProfileFlags.ALLOW_PUBLISH; - } + Flags &= ~ProfileFlags.AllowPublish; } } /// Avatar Online Status public bool Online { - get - { - return ((Flags & ProfileFlags.ONLINE) != 0); - } + get { return ((Flags & ProfileFlags.Online) != 0); } set { if (value == true) - { - Flags |= ProfileFlags.ONLINE; - } + Flags |= ProfileFlags.Online; else - { - Flags &= ~ProfileFlags.ONLINE; - } + Flags &= ~ProfileFlags.Online; } } /// Is this a mature profile public bool MaturePublish { - get - { - return ((Flags & ProfileFlags.MATURE_PUBLISH) != 0); - } + get { return ((Flags & ProfileFlags.MaturePublish) != 0); } set { if (value == true) - { - Flags |= ProfileFlags.MATURE_PUBLISH; - } + Flags |= ProfileFlags.MaturePublish; else - { - Flags &= ~ProfileFlags.MATURE_PUBLISH; - } + Flags &= ~ProfileFlags.MaturePublish; } } /// public bool Identified { - get - { - return ((Flags & ProfileFlags.IDENTIFIED) != 0); - } + get { return ((Flags & ProfileFlags.Identified) != 0); } set { if (value == true) - { - Flags |= ProfileFlags.IDENTIFIED; - } + Flags |= ProfileFlags.Identified; else - { - Flags &= ~ProfileFlags.IDENTIFIED; - } + Flags &= ~ProfileFlags.Identified; } } - ///// + /// public bool Transacted { - get - { - return ((Flags & ProfileFlags.TRANSACTED) != 0); - } + get { return ((Flags & ProfileFlags.Transacted) != 0); } set { if (value == true) - { - Flags |= ProfileFlags.TRANSACTED; - } + Flags |= ProfileFlags.Transacted; else - { - Flags &= ~ProfileFlags.TRANSACTED; - } + Flags &= ~ProfileFlags.Transacted; } } @@ -221,61 +190,68 @@ namespace OpenMetaverse public string WantToText; } - #endregion Avatar Structs - + #endregion Subclasses #region Public Members /// Groups that this avatar is a member of public List Groups = new List(); /// Positive and negative ratings - public Statistics ProfileStatistics = new Statistics(); + public Statistics ProfileStatistics; /// Avatar properties including about text, profile URL, image IDs and /// publishing settings - public AvatarProperties ProfileProperties = new AvatarProperties(); + public AvatarProperties ProfileProperties; /// Avatar interests including spoken languages, skills, and "want to" /// choices - public Interests ProfileInterests = new Interests(); - /// Simulator the avatar is in - public Simulator CurrentSim = null; + public Interests ProfileInterests; #endregion Public Members + protected string name; + protected string groupName; + + #region Properties /// Full name public string Name { get { - if (name.Length > 0) + if (!String.IsNullOrEmpty(name)) { return name; } - else if (NameValues == null || NameValues.Length == 0) - { - return String.Empty; - } else { - string firstName = String.Empty; - string lastName = String.Empty; + lock (NameValues) + { + if (NameValues == null || NameValues.Length == 0) + { + return String.Empty; + } + else + { + string firstName = String.Empty; + string lastName = String.Empty; - for (int i = 0; i < NameValues.Length; i++) - { - if (NameValues[i].Name == "FirstName" && NameValues[i].Type == NameValue.ValueType.String) - firstName = (string)NameValues[i].Value; - else if (NameValues[i].Name == "LastName" && NameValues[i].Type == NameValue.ValueType.String) - lastName = (string)NameValues[i].Value; - } + for (int i = 0; i < NameValues.Length; i++) + { + if (NameValues[i].Name == "FirstName" && NameValues[i].Type == NameValue.ValueType.String) + firstName = (string)NameValues[i].Value; + else if (NameValues[i].Name == "LastName" && NameValues[i].Type == NameValue.ValueType.String) + lastName = (string)NameValues[i].Value; + } - if (firstName != String.Empty && lastName != String.Empty) - { - name = String.Format("{0} {1}", firstName, lastName); - return name; - } - else - { - return String.Empty; + if (firstName != String.Empty && lastName != String.Empty) + { + name = String.Format("{0} {1}", firstName, lastName); + return name; + } + else + { + return String.Empty; + } + } } } } @@ -286,39 +262,39 @@ namespace OpenMetaverse { get { - for (int i = 0; i < NameValues.Length; i++) + if (!String.IsNullOrEmpty(groupName)) { - if (NameValues[i].Name == "Title" && NameValues[i].Type == NameValue.ValueType.String) + return groupName; + } + else + { + lock (NameValues) { - groupName = (string)NameValues[i].Value; - break; + if (NameValues == null || NameValues.Length == 0) + { + return String.Empty; + } + else + { + for (int i = 0; i < NameValues.Length; i++) + { + if (NameValues[i].Name == "Title" && NameValues[i].Type == NameValue.ValueType.String) + { + groupName = (string)NameValues[i].Value; + return groupName; + } + } + + return String.Empty; + } } } - - return groupName; } } - /// Gets the local ID of the prim the avatar is sitting on, - /// zero if the avatar is not currently sitting - public uint SittingOn { get { return sittingOn; } } - - - internal string name = String.Empty; - internal string groupName = String.Empty; - internal uint sittingOn - { - get - { - return ParentID; - } - - set - { - ParentID = value; - } - } + #endregion Properties + #region Constructors /// /// Default constructor @@ -326,5 +302,7 @@ namespace OpenMetaverse public Avatar() { } + + #endregion Constructors } } diff --git a/OpenMetaverse/AvatarManager.cs b/OpenMetaverse/AvatarManager.cs index f6f1ecad..37bca1c1 100644 --- a/OpenMetaverse/AvatarManager.cs +++ b/OpenMetaverse/AvatarManager.cs @@ -90,7 +90,7 @@ namespace OpenMetaverse /// /// /// - public delegate void AvatarAppearanceCallback(UUID avatarID, bool isTrial, LLObject.TextureEntryFace defaultTexture, LLObject.TextureEntryFace[] faceTextures, List visualParams); + public delegate void AvatarAppearanceCallback(UUID avatarID, bool isTrial, Primitive.TextureEntryFace defaultTexture, Primitive.TextureEntryFace[] faceTextures, List visualParams); /// /// Triggered when a UUIDNameReply is received /// @@ -386,11 +386,11 @@ namespace OpenMetaverse visualParams.Add(block.ParamValue); } - LLObject.TextureEntry textureEntry = new Primitive.TextureEntry(appearance.ObjectData.TextureEntry, 0, + Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(appearance.ObjectData.TextureEntry, 0, appearance.ObjectData.TextureEntry.Length); - LLObject.TextureEntryFace defaultTexture = textureEntry.DefaultTexture; - LLObject.TextureEntryFace[] faceTextures = textureEntry.FaceTextures; + Primitive.TextureEntryFace defaultTexture = textureEntry.DefaultTexture; + Primitive.TextureEntryFace[] faceTextures = textureEntry.FaceTextures; try { OnAvatarAppearance(appearance.Sender.ID, appearance.Sender.IsTrial, defaultTexture, faceTextures, visualParams); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } diff --git a/OpenMetaverse/Interfaces/IRendering.cs b/OpenMetaverse/Interfaces/IRendering.cs index 68685bfd..626af975 100644 --- a/OpenMetaverse/Interfaces/IRendering.cs +++ b/OpenMetaverse/Interfaces/IRendering.cs @@ -75,6 +75,6 @@ namespace OpenMetaverse.Rendering /// Vertex list to modify texture coordinates for /// Center-point of the face /// Face texture parameters - void TransformTexCoords(List vertices, Vector3 center, LLObject.TextureEntryFace teFace); + void TransformTexCoords(List vertices, Vector3 center, Primitive.TextureEntryFace teFace); } } diff --git a/OpenMetaverse/LLObject.cs b/OpenMetaverse/LLObject.cs deleted file mode 100644 index 9f9f680d..00000000 --- a/OpenMetaverse/LLObject.cs +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Copyright (c) 2007-2008, openmetaverse.org - * All rights reserved. - * - * - 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. - * - Neither the name of the openmetaverse.org 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Generic; -using OpenMetaverse.Packets; - -namespace OpenMetaverse -{ - /// - /// Base class for primitives and avatars - /// - public abstract partial class LLObject - { - // Used for packing and unpacking parameters - protected const float CUT_QUANTA = 0.00002f; - protected const float SCALE_QUANTA = 0.01f; - protected const float SHEAR_QUANTA = 0.01f; - protected const float TAPER_QUANTA = 0.01f; - protected const float REV_QUANTA = 0.015f; - protected const float HOLLOW_QUANTA = 0.00002f; - - #region Enumerations - - /// - /// Primary parameters for primitives such as Physics Enabled or Phantom - /// - [Flags] - public enum ObjectFlags : uint - { - /// None of the primary flags are enabled - None = 0, - /// Whether physics are enabled for this object - Physics = 0x00000001, - /// - CreateSelected = 0x00000002, - /// - ObjectModify = 0x00000004, - /// - ObjectCopy = 0x00000008, - /// - ObjectAnyOwner = 0x00000010, - /// - ObjectYouOwner = 0x00000020, - /// - Scripted = 0x00000040, - /// Whether this object contains an active touch script - Touch = 0x00000080, - /// - ObjectMove = 0x00000100, - /// Whether this object can receive payments - Money = 0x00000200, - /// Whether this object is phantom (no collisions) - Phantom = 0x00000400, - /// - InventoryEmpty = 0x00000800, - /// - JointHinge = 0x00001000, - /// - JointP2P = 0x00002000, - /// - JointLP2P = 0x00004000, - /// Deprecated - JointWheel = 0x00008000, - /// - AllowInventoryDrop = 0x00010000, - /// - ObjectTransfer = 0x00020000, - /// - ObjectGroupOwned = 0x00040000, - /// Deprecated - ObjectYouOfficer = 0x00080000, - /// - CameraDecoupled = 0x00100000, - /// - AnimSource = 0x00200000, - /// - CameraSource = 0x00400000, - /// - CastShadows = 0x00800000, - /// - ObjectOwnerModify = 0x10000000, - /// - TemporaryOnRez = 0x20000000, - /// - Temporary = 0x40000000, - /// - ZlibCompressed = 0x80000000 - } - - public enum ProfileCurve : byte - { - Circle = 0x00, - Square = 0x01, - IsoTriangle = 0x02, - EqualTriangle = 0x03, - RightTriangle = 0x04, - HalfCircle = 0x05 - } - - public enum HoleType : byte - { - Same = 0x00, - Circle = 0x10, - Square = 0x20, - Triangle = 0x30 - } - - public enum PathCurve : byte - { - Line = 0x10, - Circle = 0x20, - Circle2 = 0x30, - Test = 0x40, - Flexible = 0x80 - } - - /// - /// Material type for a primitive - /// - public enum MaterialType : byte - { - /// - Stone = 0, - /// - Metal, - /// - Glass, - /// - Wood, - /// - Flesh, - /// - Plastic, - /// - Rubber, - /// - Light - } - - public enum PrimType - { - Unknown, - Box, - Cylinder, - Prism, - Sphere, - Torus, - Tube, - Ring, - Sculpt - } - - #endregion Enumerations - - #region Structs - - /// - /// - /// - public struct ObjectData - { - private const byte PROFILE_MASK = 0x0F; - private const byte HOLE_MASK = 0xF0; - - /// - internal byte profileCurve; - - /// - public PathCurve PathCurve; - /// - public float PathEnd; - /// - public float PathRadiusOffset; - /// - public float PathSkew; - /// - public float PathScaleX; - /// - public float PathScaleY; - /// - public float PathShearX; - /// - public float PathShearY; - /// - public float PathTaperX; - /// - public float PathTaperY; - /// - public float PathBegin; - /// - public float PathTwist; - /// - public float PathTwistBegin; - /// - public float PathRevolutions; - /// - public float ProfileBegin; - /// - public float ProfileEnd; - /// - public float ProfileHollow; - - /// - public MaterialType Material; - /// - public byte State; - /// - public PCode PCode; - - #region Properties - - /// - public ProfileCurve ProfileCurve - { - get { return (ProfileCurve)(profileCurve & PROFILE_MASK); } - set - { - profileCurve &= HOLE_MASK; - profileCurve |= (byte)value; - } - } - - /// - public HoleType ProfileHole - { - get { return (HoleType)(profileCurve & HOLE_MASK); } - set - { - profileCurve &= PROFILE_MASK; - profileCurve |= (byte)value; - } - } - - /// - public Vector2 PathBeginScale - { - get - { - Vector2 begin = new Vector2(1f, 1f); - if (PathScaleX > 1f) - begin.X = 2f - PathScaleX; - if (PathScaleY > 1f) - begin.Y = 2f - PathScaleY; - return begin; - } - } - - /// - public Vector2 PathEndScale - { - get - { - Vector2 end = new Vector2(1f, 1f); - if (PathScaleX < 1f) - end.X = PathScaleX; - if (PathScaleY < 1f) - end.Y = PathScaleY; - return end; - } - } - - public PrimType Type - { - get - { - bool linearPath = (PathCurve == LLObject.PathCurve.Line || PathCurve == LLObject.PathCurve.Flexible); - float scaleX = PathScaleX; - float scaleY = PathScaleY; - - if (linearPath && ProfileCurve == LLObject.ProfileCurve.Circle) - return PrimType.Cylinder; - else if (linearPath && ProfileCurve == LLObject.ProfileCurve.Square) - return PrimType.Box; - else if (linearPath && ProfileCurve == LLObject.ProfileCurve.IsoTriangle) - return PrimType.Prism; - else if (linearPath && ProfileCurve == LLObject.ProfileCurve.EqualTriangle) - return PrimType.Prism; - else if (linearPath && ProfileCurve == LLObject.ProfileCurve.RightTriangle) - return PrimType.Prism; - else if (PathCurve == LLObject.PathCurve.Flexible) - return PrimType.Unknown; - else if (PathCurve == LLObject.PathCurve.Circle && ProfileCurve == LLObject.ProfileCurve.Circle && scaleY > 0.75f) - return PrimType.Sphere; - else if (PathCurve == LLObject.PathCurve.Circle && ProfileCurve == LLObject.ProfileCurve.Circle && scaleY <= 0.75f) - return PrimType.Torus; - else if (PathCurve == LLObject.PathCurve.Circle && ProfileCurve == LLObject.ProfileCurve.HalfCircle) - return PrimType.Sphere; - else if (PathCurve == LLObject.PathCurve.Circle2 && ProfileCurve == LLObject.ProfileCurve.Circle) - return PrimType.Sphere; // Spiral/sphere - else if (PathCurve == LLObject.PathCurve.Circle && ProfileCurve == LLObject.ProfileCurve.EqualTriangle) - return PrimType.Ring; - else if (PathCurve == LLObject.PathCurve.Circle && ProfileCurve == LLObject.ProfileCurve.Square && scaleY <= 0.75f) - return PrimType.Tube; - else - return PrimType.Unknown; - } - } - - #endregion Properties - - public override string ToString() - { - return Type.ToString(); - } - } - - /// - /// - /// - public struct ObjectProperties - { - /// - public UUID ObjectID; - /// - public UUID CreatorID; - /// This is a protocol hack, it will only be set if the - /// object has a non-null sound so you can mute the owner - public UUID OwnerID; - /// - public UUID GroupID; - /// - public ulong CreationDate; - /// - public Permissions Permissions; - /// - public int OwnershipCost; - /// - public byte SaleType; - /// - public int SalePrice; - /// - public byte AggregatePerms; - /// - public byte AggregatePermTextures; - /// - public byte AggregatePermTexturesOwner; - /// - public uint Category; - /// - public short InventorySerial; - /// - public UUID ItemID; - /// - public UUID FolderID; - /// - public UUID FromTaskID; - /// - public UUID LastOwnerID; - /// - public string Name; - /// - public string Description; - /// - public string TouchName; - /// - public string SitName; - /// - public UUID[] TextureIDs; - } - - /// - /// - /// - public struct ObjectPropertiesFamily - { - /// - /// - /// - public enum RequestFlagsType - { - /// - None = 0, - /// - BugReportRequest = 1, - /// - ComplaintReportRequest = 2 - } - - /// - public RequestFlagsType RequestFlags; - /// - public UUID ObjectID; - /// - public UUID OwnerID; - /// - public UUID GroupID; - /// - public Permissions Permissions; - /// - public int OwnershipCost; - /// - public byte SaleType; - /// - public int SalePrice; - /// - public uint Category; - /// - public UUID LastOwnerID; - /// - public string Name; - /// - public string Description; - - //public bool IsOwnedBy(GridClient client) - //{ - // if (GroupID != UUID.Zero) - // { - // // Group owned, iterate through all of this clients groups - // // and see if it is a member - // //client.Groups. - // // FIXME: Current groups should be stored in GroupManager and auto-requested (with a setting to turn off) - // } - // else - // { - // // Avatar owned - // } - //} - } - - #endregion Structs - - #region Public Members - - /// - public UUID ID; - /// - public UUID GroupID; - /// - public uint LocalID; - /// - public uint ParentID; - /// - public ulong RegionHandle; - /// - public ObjectFlags Flags; - /// Unknown - public byte[] GenericData; - /// - public Vector3 Position; - /// - public Vector3 Scale; - /// - public Quaternion Rotation; - /// - public Vector3 Velocity; - /// - public Vector3 AngularVelocity; - /// - public Vector3 Acceleration; - /// - public Vector4 CollisionPlane; - /// - public TextureEntry Textures; - /// - public ObjectProperties Properties; - /// - public ObjectPropertiesFamily PropertiesFamily; - /// - public NameValue[] NameValues; - /// - public ObjectData Data; - - #endregion Public Members - - /// - /// - /// - /// - /// - public override bool Equals(object obj) - { - LLObject llobj = obj as LLObject; - if (llobj == null) - return false; - return ID.Equals(llobj.ID); - } - - /// - /// - /// - /// - public override int GetHashCode() - { - return ID.GetHashCode(); - } - - #region Parameter Packing Methods - - public static ushort PackBeginCut(float beginCut) - { - return (ushort)Math.Round(beginCut / CUT_QUANTA); - } - - public static ushort PackEndCut(float endCut) - { - return (ushort)(50000 - (ushort)Math.Round(endCut / CUT_QUANTA)); - } - - public static byte PackPathScale(float pathScale) - { - return (byte)(200 - (byte)Math.Round(pathScale / SCALE_QUANTA)); - } - - public static sbyte PackPathShear(float pathShear) - { - return (sbyte)Math.Round(pathShear / SHEAR_QUANTA); - } - - /// - /// Packs PathTwist, PathTwistBegin, PathRadiusOffset, and PathSkew - /// parameters in to signed eight bit values - /// - /// Floating point parameter to pack - /// Signed eight bit value containing the packed parameter - public static sbyte PackPathTwist(float pathTwist) - { - return (sbyte)Math.Round(pathTwist / SCALE_QUANTA); - } - - public static sbyte PackPathTaper(float pathTaper) - { - return (sbyte)Math.Round(pathTaper / TAPER_QUANTA); - } - - public static byte PackPathRevolutions(float pathRevolutions) - { - return (byte)Math.Round((pathRevolutions - 1f) / REV_QUANTA); - } - - public static ushort PackProfileHollow(float profileHollow) - { - return (ushort)Math.Round(profileHollow / HOLLOW_QUANTA); - } - - #endregion Parameter Packing Methods - - #region Parameter Unpacking Methods - - public static float UnpackBeginCut(ushort beginCut) - { - return (float)beginCut * CUT_QUANTA; - } - - public static float UnpackEndCut(ushort endCut) - { - return (float)(50000 - endCut) * CUT_QUANTA; - } - - public static float UnpackPathScale(byte pathScale) - { - return (float)(200 - pathScale) * SCALE_QUANTA; - } - - public static float UnpackPathShear(sbyte pathShear) - { - return (float)pathShear * SHEAR_QUANTA; - } - - /// - /// Unpacks PathTwist, PathTwistBegin, PathRadiusOffset, and PathSkew - /// parameters from signed eight bit integers to floating point values - /// - /// Signed eight bit value to unpack - /// Unpacked floating point value - public static float UnpackPathTwist(sbyte pathTwist) - { - return (float)pathTwist * SCALE_QUANTA; - } - - public static float UnpackPathTaper(sbyte pathTaper) - { - return (float)pathTaper * TAPER_QUANTA; - } - - public static float UnpackPathRevolutions(byte pathRevolutions) - { - return (float)pathRevolutions * REV_QUANTA + 1f; - } - - public static float UnpackProfileHollow(ushort profileHollow) - { - return (float)profileHollow * HOLLOW_QUANTA; - } - - #endregion Parameter Unpacking Methods - } -} diff --git a/OpenMetaverse/ObjectManager.cs b/OpenMetaverse/ObjectManager.cs index c2c3e088..8ee39fce 100644 --- a/OpenMetaverse/ObjectManager.cs +++ b/OpenMetaverse/ObjectManager.cs @@ -34,112 +34,16 @@ namespace OpenMetaverse #region Enums /// - /// Identifier code for object types + /// /// - public enum PCode : byte + public enum ObjectPropertiesRequestType { - /// None + /// None = 0, - /// A Primitive - Prim = 9, - /// A Avatar - Avatar = 47, - /// Linden grass - Grass = 95, - /// Linden tree - NewTree = 111, - /// A primitive that acts as the source for a particle stream - ParticleSystem = 143, - /// A Linden tree - Tree = 255 - } - - /// - /// Attachment points for objects on avatar bodies - /// - /// - /// Both InventoryObject and InventoryAttachment types can be attached - /// - public enum AttachmentPoint : byte - { - /// Right hand if object was not previously attached - Default = 0, - /// Chest - Chest = 1, - /// Skull - Skull, - /// Left shoulder - LeftShoulder, - /// Right shoulder - RightShoulder, - /// Left hand - LeftHand, - /// Right hand - RightHand, - /// Left foot - LeftFoot, - /// Right foot - RightFoot, - /// Spine - Spine, - /// Pelvis - Pelvis, - /// Mouth - Mouth, - /// Chin - Chin, - /// Left ear - LeftEar, - /// Right ear - RightEar, - /// Left eyeball - LeftEyeball, - /// Right eyeball - RightEyeball, - /// Nose - Nose, - /// Right upper arm - RightUpperArm, - /// Right forearm - RightForearm, - /// Left upper arm - LeftUpperArm, - /// Left forearm - LeftForearm, - /// Right hip - RightHip, - /// Right upper leg - RightUpperLeg, - /// Right lower leg - RightLowerLeg, - /// Left hip - LeftHip, - /// Left upper leg - LeftUpperLeg, - /// Left lower leg - LeftLowerLeg, - /// Stomach - Stomach, - /// Left pectoral - LeftPec, - /// Right pectoral - RightPec, - /// HUD Center position 2 - HUDCenter2, - /// HUD Top-right - HUDTopRight, - /// HUD Top - HUDTop, - /// HUD Top-left - HUDTopLeft, - /// HUD Center - HUDCenter, - /// HUD Bottom-left - HUDBottomLeft, - /// HUD Bottom - HUDBottom, - /// HUD Bottom-right - HUDBottomRight + /// + BugReportRequest = 1, + /// + ComplaintReportRequest = 2 } /// @@ -171,95 +75,6 @@ namespace OpenMetaverse MediaURL = 0x200 } - /// - /// Tree foliage types - /// - public enum Tree : byte - { - /// Pine1 tree - Pine1 = 0, - /// Oak tree - Oak, - /// Tropical Bush1 - TropicalBush1, - /// Palm1 tree - Palm1, - /// Dogwood tree - Dogwood, - /// Tropical Bush2 - TropicalBush2, - /// Palm2 tree - Palm2, - /// Cypress1 tree - Cypress1, - /// Cypress2 tree - Cypress2, - /// Pine2 tree - Pine2, - /// Plumeria - Plumeria, - /// Winter pinetree1 - WinterPine1, - /// Winter Aspen tree - WinterAspen, - /// Winter pinetree2 - WinterPine2, - /// Eucalyptus tree - Eucalyptus, - /// Fern - Fern, - /// Eelgrass - Eelgrass, - /// Sea Sword - SeaSword, - /// Kelp1 plant - Kelp1, - /// Beach grass - BeachGrass1, - /// Kelp2 plant - Kelp2 - } - - /// - /// Grass foliage types - /// - public enum Grass : byte - { - /// - Grass0 = 0, - /// - Grass1, - /// - Grass2, - /// - Grass3, - /// - Grass4, - /// - Undergrowth1 - } - - /// - /// Action associated with clicking on an object - /// - public enum ClickAction : byte - { - /// Touch object - Touch = 0, - /// Sit on object - Sit = 1, - /// Purchase object or contents - Buy = 2, - /// Pay the object - Pay = 3, - /// Open task inventory - OpenTask = 4, - /// Play parcel media - PlayMedia = 5, - /// Open parcel media - OpenMedia = 6 - } - /// /// Specific Flags for MultipleObjectUpdate requests /// @@ -309,7 +124,7 @@ namespace OpenMetaverse /// public Vector3 AngularVelocity; /// - public LLObject.TextureEntry Textures; + public Primitive.TextureEntry Textures; } #endregion Structs @@ -346,15 +161,16 @@ namespace OpenMetaverse /// /// /// - /// - public delegate void ObjectPropertiesCallback(Simulator simulator, LLObject.ObjectProperties properties); + /// + public delegate void ObjectPropertiesCallback(Simulator simulator, Primitive.ObjectProperties props); /// /// /// /// - /// - public delegate void ObjectPropertiesFamilyCallback(Simulator simulator, - LLObject.ObjectPropertiesFamily properties); + /// + /// + public delegate void ObjectPropertiesFamilyCallback(Simulator simulator, Primitive.ObjectProperties props, + ObjectPropertiesRequestType type); /// /// /// @@ -512,7 +328,7 @@ namespace OpenMetaverse Client.Network.RegisterCallback(PacketType.ImprovedTerseObjectUpdate, new NetworkManager.PacketCallback(TerseUpdateHandler)); Client.Network.RegisterCallback(PacketType.ObjectUpdateCompressed, new NetworkManager.PacketCallback(CompressedUpdateHandler)); Client.Network.RegisterCallback(PacketType.ObjectUpdateCached, new NetworkManager.PacketCallback(CachedUpdateHandler)); - Client.Network.RegisterCallback(PacketType.KillObject, new NetworkManager.PacketCallback(KillObjectHandler)); + Client.Network.RegisterCallback(PacketType.KiPrimitive, new NetworkManager.PacketCallback(KiPrimitiveHandler)); Client.Network.RegisterCallback(PacketType.ObjectPropertiesFamily, new NetworkManager.PacketCallback(ObjectPropertiesFamilyHandler)); Client.Network.RegisterCallback(PacketType.ObjectProperties, new NetworkManager.PacketCallback(ObjectPropertiesHandler)); @@ -741,7 +557,7 @@ namespace OpenMetaverse /// follow up by moving the object after it has been created. This /// function will not set textures, light and flexible data, or other /// extended primitive properties - public void AddPrim(Simulator simulator, LLObject.ObjectData prim, UUID groupID, Vector3 position, + public void AddPrim(Simulator simulator, Primitive.ConstructionData prim, UUID groupID, Vector3 position, Vector3 scale, Quaternion rotation) { ObjectAddPacket packet = new ObjectAddPacket(); @@ -751,7 +567,7 @@ namespace OpenMetaverse packet.AgentData.GroupID = groupID; packet.ObjectData.State = prim.State; - packet.ObjectData.AddFlags = (uint)LLObject.ObjectFlags.CreateSelected; + packet.ObjectData.AddFlags = (uint)PrimFlags.CreateSelected; packet.ObjectData.PCode = (byte)PCode.Prim; packet.ObjectData.Material = (byte)prim.Material; @@ -759,24 +575,24 @@ namespace OpenMetaverse packet.ObjectData.Rotation = rotation; packet.ObjectData.PathCurve = (byte)prim.PathCurve; - packet.ObjectData.PathBegin = LLObject.PackBeginCut(prim.PathBegin); - packet.ObjectData.PathEnd = LLObject.PackEndCut(prim.PathEnd); - packet.ObjectData.PathRadiusOffset = LLObject.PackPathTwist(prim.PathRadiusOffset); - packet.ObjectData.PathRevolutions = LLObject.PackPathRevolutions(prim.PathRevolutions); - packet.ObjectData.PathScaleX = LLObject.PackPathScale(prim.PathScaleX); - packet.ObjectData.PathScaleY = LLObject.PackPathScale(prim.PathScaleY); - packet.ObjectData.PathShearX = (byte)LLObject.PackPathShear(prim.PathShearX); - packet.ObjectData.PathShearY = (byte)LLObject.PackPathShear(prim.PathShearY); - packet.ObjectData.PathSkew = LLObject.PackPathTwist(prim.PathSkew); - packet.ObjectData.PathTaperX = LLObject.PackPathTaper(prim.PathTaperX); - packet.ObjectData.PathTaperY = LLObject.PackPathTaper(prim.PathTaperY); - packet.ObjectData.PathTwist = LLObject.PackPathTwist(prim.PathTwist); - packet.ObjectData.PathTwistBegin = LLObject.PackPathTwist(prim.PathTwistBegin); + packet.ObjectData.PathBegin = Primitive.PackBeginCut(prim.PathBegin); + packet.ObjectData.PathEnd = Primitive.PackEndCut(prim.PathEnd); + packet.ObjectData.PathRadiusOffset = Primitive.PackPathTwist(prim.PathRadiusOffset); + packet.ObjectData.PathRevolutions = Primitive.PackPathRevolutions(prim.PathRevolutions); + packet.ObjectData.PathScaleX = Primitive.PackPathScale(prim.PathScaleX); + packet.ObjectData.PathScaleY = Primitive.PackPathScale(prim.PathScaleY); + packet.ObjectData.PathShearX = (byte)Primitive.PackPathShear(prim.PathShearX); + packet.ObjectData.PathShearY = (byte)Primitive.PackPathShear(prim.PathShearY); + packet.ObjectData.PathSkew = Primitive.PackPathTwist(prim.PathSkew); + packet.ObjectData.PathTaperX = Primitive.PackPathTaper(prim.PathTaperX); + packet.ObjectData.PathTaperY = Primitive.PackPathTaper(prim.PathTaperY); + packet.ObjectData.PathTwist = Primitive.PackPathTwist(prim.PathTwist); + packet.ObjectData.PathTwistBegin = Primitive.PackPathTwist(prim.PathTwistBegin); packet.ObjectData.ProfileCurve = prim.profileCurve; - packet.ObjectData.ProfileBegin = LLObject.PackBeginCut(prim.ProfileBegin); - packet.ObjectData.ProfileEnd = LLObject.PackEndCut(prim.ProfileEnd); - packet.ObjectData.ProfileHollow = LLObject.PackProfileHollow(prim.ProfileHollow); + packet.ObjectData.ProfileBegin = Primitive.PackBeginCut(prim.ProfileBegin); + packet.ObjectData.ProfileEnd = Primitive.PackEndCut(prim.ProfileEnd); + packet.ObjectData.ProfileHollow = Primitive.PackProfileHollow(prim.ProfileHollow); packet.ObjectData.RayStart = position; packet.ObjectData.RayEnd = position; @@ -858,7 +674,7 @@ namespace OpenMetaverse /// A reference to the object where the object resides /// The objects ID which is local to the simulator the object is in /// The texture data to apply - public void SetTextures(Simulator simulator, uint localID, LLObject.TextureEntry textures) + public void SetTextures(Simulator simulator, uint localID, Primitive.TextureEntry textures) { SetTextures(simulator, localID, textures, String.Empty); } @@ -870,7 +686,7 @@ namespace OpenMetaverse /// The objects ID which is local to the simulator the object is in /// The texture data to apply /// A media URL (not used) - public void SetTextures(Simulator simulator, uint localID, LLObject.TextureEntry textures, string mediaUrl) + public void SetTextures(Simulator simulator, uint localID, Primitive.TextureEntry textures, string mediaUrl) { ObjectImagePacket image = new ObjectImagePacket(); @@ -900,7 +716,7 @@ namespace OpenMetaverse extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; - extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Light; + extra.ObjectData[0].ParamType = (byte)ExtraParamType.Light; if (light.Intensity == 0.0f) { // Disables the light if intensity is 0 @@ -931,7 +747,7 @@ namespace OpenMetaverse extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; - extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Flexible; + extra.ObjectData[0].ParamType = (byte)ExtraParamType.Flexible; extra.ObjectData[0].ParamInUse = true; extra.ObjectData[0].ParamData = flexible.GetBytes(); extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length; @@ -955,7 +771,7 @@ namespace OpenMetaverse extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; - extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Sculpt; + extra.ObjectData[0].ParamType = (byte)ExtraParamType.Sculpt; extra.ObjectData[0].ParamInUse = true; extra.ObjectData[0].ParamData = sculpt.GetBytes(); extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length; @@ -984,7 +800,7 @@ namespace OpenMetaverse /// A reference to the object where the object resides /// The objects ID which is local to the simulator the object is in /// The extra parameters to set - public void SetExtraParamOff(Simulator simulator, uint localID, Primitive.ExtraParamType type) + public void SetExtraParamOff(Simulator simulator, uint localID, ExtraParamType type) { ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket(); @@ -1466,27 +1282,27 @@ namespace OpenMetaverse #endregion NameValue parsing #region Decode Object (primitive) parameters - LLObject.ObjectData data = new LLObject.ObjectData(); + Primitive.ConstructionData data = new Primitive.ConstructionData(); data.State = block.State; - data.Material = (LLObject.MaterialType)block.Material; - data.PathCurve = (LLObject.PathCurve)block.PathCurve; + data.Material = (Material)block.Material; + data.PathCurve = (PathCurve)block.PathCurve; data.profileCurve = block.ProfileCurve; - data.PathBegin = LLObject.UnpackBeginCut(block.PathBegin); - data.PathEnd = LLObject.UnpackEndCut(block.PathEnd); - data.PathScaleX = LLObject.UnpackPathScale(block.PathScaleX); - data.PathScaleY = LLObject.UnpackPathScale(block.PathScaleY); - data.PathShearX = LLObject.UnpackPathShear((sbyte)block.PathShearX); - data.PathShearY = LLObject.UnpackPathShear((sbyte)block.PathShearY); - data.PathTwist = LLObject.UnpackPathTwist(block.PathTwist); - data.PathTwistBegin = LLObject.UnpackPathTwist(block.PathTwistBegin); - data.PathRadiusOffset = LLObject.UnpackPathTwist(block.PathRadiusOffset); - data.PathTaperX = LLObject.UnpackPathTaper(block.PathTaperX); - data.PathTaperY = LLObject.UnpackPathTaper(block.PathTaperY); - data.PathRevolutions = LLObject.UnpackPathRevolutions(block.PathRevolutions); - data.PathSkew = LLObject.UnpackPathTwist(block.PathSkew); - data.ProfileBegin = LLObject.UnpackBeginCut(block.ProfileBegin); - data.ProfileEnd = LLObject.UnpackEndCut(block.ProfileEnd); - data.ProfileHollow = LLObject.UnpackProfileHollow(block.ProfileHollow); + data.PathBegin = Primitive.UnpackBeginCut(block.PathBegin); + data.PathEnd = Primitive.UnpackEndCut(block.PathEnd); + data.PathScaleX = Primitive.UnpackPathScale(block.PathScaleX); + data.PathScaleY = Primitive.UnpackPathScale(block.PathScaleY); + data.PathShearX = Primitive.UnpackPathShear((sbyte)block.PathShearX); + data.PathShearY = Primitive.UnpackPathShear((sbyte)block.PathShearY); + data.PathTwist = Primitive.UnpackPathTwist(block.PathTwist); + data.PathTwistBegin = Primitive.UnpackPathTwist(block.PathTwistBegin); + data.PathRadiusOffset = Primitive.UnpackPathTwist(block.PathRadiusOffset); + data.PathTaperX = Primitive.UnpackPathTaper(block.PathTaperX); + data.PathTaperY = Primitive.UnpackPathTaper(block.PathTaperY); + data.PathRevolutions = Primitive.UnpackPathRevolutions(block.PathRevolutions); + data.PathSkew = Primitive.UnpackPathTwist(block.PathSkew); + data.ProfileBegin = Primitive.UnpackBeginCut(block.ProfileBegin); + data.ProfileEnd = Primitive.UnpackEndCut(block.ProfileEnd); + data.ProfileHollow = Primitive.UnpackProfileHollow(block.ProfileHollow); data.PCode = pcode; #endregion @@ -1615,9 +1431,9 @@ namespace OpenMetaverse Primitive prim = GetPrimitive(simulator, block.ID, block.FullID); #region Update Prim Info with decoded data - prim.Flags = (LLObject.ObjectFlags)block.UpdateFlags; + prim.Flags = (PrimFlags)block.UpdateFlags; - if ((prim.Flags & LLObject.ObjectFlags.ZlibCompressed) != 0) + if ((prim.Flags & PrimFlags.ZlibCompressed) != 0) { Logger.Log("Got a ZlibCompressed ObjectUpdate, implement me!", Helpers.LogLevel.Warning, Client); @@ -1625,7 +1441,7 @@ namespace OpenMetaverse } // Automatically request ObjectProperties for prim if it was rezzed selected. - if ((prim.Flags & LLObject.ObjectFlags.CreateSelected) == LLObject.ObjectFlags.CreateSelected) + if ((prim.Flags & PrimFlags.CreateSelected) == PrimFlags.CreateSelected) SelectObject(simulator, prim.LocalID); prim.NameValues = nameValues; @@ -1647,15 +1463,15 @@ namespace OpenMetaverse prim.SoundRadius = block.Radius; // Joint information - prim.Joint = (Primitive.JointType)block.JointType; + prim.Joint = (JointType)block.JointType; prim.JointPivot = block.JointPivot; prim.JointAxisOrAnchor = block.JointAxisOrAnchor; // Object parameters - prim.Data = data; + prim.PrimData = data; // Textures, texture animations, particle system, and extra params - prim.Textures = new LLObject.TextureEntry(block.TextureEntry, 0, + prim.Textures = new Primitive.TextureEntry(block.TextureEntry, 0, block.TextureEntry.Length); prim.TextureAnim = new Primitive.TextureAnimation(block.TextureAnim, 0); @@ -1710,7 +1526,7 @@ namespace OpenMetaverse #region Create an Avatar from the decoded data Avatar avatar = GetAvatar(simulator, block.ID, block.FullID); - uint oldSeatID = avatar.sittingOn; + uint oldSeatID = avatar.ParentID; avatar.ID = block.FullID; avatar.LocalID = block.ID; @@ -1721,15 +1537,12 @@ namespace OpenMetaverse avatar.Rotation = rotation; avatar.AngularVelocity = angularVelocity; avatar.NameValues = nameValues; - avatar.Data = data; + avatar.PrimData = data; avatar.GenericData = block.Data; - avatar.sittingOn = block.ParentID; + avatar.ParentID = block.ParentID; SetAvatarSittingOn(simulator, avatar, block.ParentID, oldSeatID); - // Set the current simulator for this avatar - avatar.CurrentSim = simulator; - // Textures avatar.Textures = new Primitive.TextureEntry(block.TextureEntry, 0, block.TextureEntry.Length); @@ -1867,13 +1680,13 @@ namespace OpenMetaverse // Textures // FIXME: Why are we ignoring the first four bytes here? if (block.TextureEntry.Length != 0) - update.Textures = new LLObject.TextureEntry(block.TextureEntry, 4, block.TextureEntry.Length - 4); + update.Textures = new Primitive.TextureEntry(block.TextureEntry, 4, block.TextureEntry.Length - 4); #endregion Decode update data - LLObject obj = (update.Avatar) ? - (LLObject)GetAvatar(simulator, update.LocalID, null): - (LLObject)GetPrimitive(simulator, update.LocalID, null); + Primitive obj = (update.Avatar) ? + (Primitive)GetAvatar(simulator, update.LocalID, null): + (Primitive)GetPrimitive(simulator, update.LocalID, null); #region Update Client.Self if (update.LocalID == Client.Self.localID) @@ -1952,8 +1765,8 @@ namespace OpenMetaverse prim.LocalID = LocalID; prim.ID = FullID; - prim.Flags = (LLObject.ObjectFlags)block.UpdateFlags; - prim.Data.PCode = pcode; + prim.Flags = (PrimFlags)block.UpdateFlags; + prim.PrimData.PCode = pcode; switch (pcode) { @@ -1963,11 +1776,11 @@ namespace OpenMetaverse #region Foliage Decoding // State - prim.Data.State = block.Data[i++]; + prim.PrimData.State = block.Data[i++]; // CRC i += 4; // Material - prim.Data.Material = (LLObject.MaterialType)block.Data[i++]; + prim.PrimData.Material = (Material)block.Data[i++]; // Click action prim.ClickAction = (ClickAction)block.Data[i++]; // Scale @@ -1992,11 +1805,11 @@ namespace OpenMetaverse case PCode.Prim: #region Decode block and update Prim // State - prim.Data.State = block.Data[i++]; + prim.PrimData.State = block.Data[i++]; // CRC i += 4; // Material - prim.Data.Material = (LLObject.MaterialType)block.Data[i++]; + prim.PrimData.Material = (Material)block.Data[i++]; // Click action prim.ClickAction = (ClickAction)block.Data[i++]; // Scale @@ -2144,35 +1957,35 @@ namespace OpenMetaverse } } - prim.Data.PathCurve = (LLObject.PathCurve)block.Data[i++]; + prim.PrimData.PathCurve = (PathCurve)block.Data[i++]; ushort pathBegin = Helpers.BytesToUInt16(block.Data, i); i += 2; - prim.Data.PathBegin = LLObject.UnpackBeginCut(pathBegin); + prim.PrimData.PathBegin = Primitive.UnpackBeginCut(pathBegin); ushort pathEnd = Helpers.BytesToUInt16(block.Data, i); i += 2; - prim.Data.PathEnd = LLObject.UnpackEndCut(pathEnd); - prim.Data.PathScaleX = LLObject.UnpackPathScale(block.Data[i++]); - prim.Data.PathScaleY = LLObject.UnpackPathScale(block.Data[i++]); - prim.Data.PathShearX = LLObject.UnpackPathShear((sbyte)block.Data[i++]); - prim.Data.PathShearY = LLObject.UnpackPathShear((sbyte)block.Data[i++]); - prim.Data.PathTwist = LLObject.UnpackPathTwist((sbyte)block.Data[i++]); - prim.Data.PathTwistBegin = LLObject.UnpackPathTwist((sbyte)block.Data[i++]); - prim.Data.PathRadiusOffset = LLObject.UnpackPathTwist((sbyte)block.Data[i++]); - prim.Data.PathTaperX = LLObject.UnpackPathTaper((sbyte)block.Data[i++]); - prim.Data.PathTaperY = LLObject.UnpackPathTaper((sbyte)block.Data[i++]); - prim.Data.PathRevolutions = LLObject.UnpackPathRevolutions(block.Data[i++]); - prim.Data.PathSkew = LLObject.UnpackPathTwist((sbyte)block.Data[i++]); + prim.PrimData.PathEnd = Primitive.UnpackEndCut(pathEnd); + prim.PrimData.PathScaleX = Primitive.UnpackPathScale(block.Data[i++]); + prim.PrimData.PathScaleY = Primitive.UnpackPathScale(block.Data[i++]); + prim.PrimData.PathShearX = Primitive.UnpackPathShear((sbyte)block.Data[i++]); + prim.PrimData.PathShearY = Primitive.UnpackPathShear((sbyte)block.Data[i++]); + prim.PrimData.PathTwist = Primitive.UnpackPathTwist((sbyte)block.Data[i++]); + prim.PrimData.PathTwistBegin = Primitive.UnpackPathTwist((sbyte)block.Data[i++]); + prim.PrimData.PathRadiusOffset = Primitive.UnpackPathTwist((sbyte)block.Data[i++]); + prim.PrimData.PathTaperX = Primitive.UnpackPathTaper((sbyte)block.Data[i++]); + prim.PrimData.PathTaperY = Primitive.UnpackPathTaper((sbyte)block.Data[i++]); + prim.PrimData.PathRevolutions = Primitive.UnpackPathRevolutions(block.Data[i++]); + prim.PrimData.PathSkew = Primitive.UnpackPathTwist((sbyte)block.Data[i++]); - prim.Data.profileCurve = block.Data[i++]; + prim.PrimData.profileCurve = block.Data[i++]; ushort profileBegin = Helpers.BytesToUInt16(block.Data, i); i += 2; - prim.Data.ProfileBegin = LLObject.UnpackBeginCut(profileBegin); + prim.PrimData.ProfileBegin = Primitive.UnpackBeginCut(profileBegin); ushort profileEnd = Helpers.BytesToUInt16(block.Data, i); i += 2; - prim.Data.ProfileEnd = LLObject.UnpackEndCut(profileEnd); + prim.PrimData.ProfileEnd = Primitive.UnpackEndCut(profileEnd); ushort profileHollow = Helpers.BytesToUInt16(block.Data, i); i += 2; - prim.Data.ProfileHollow = LLObject.UnpackProfileHollow(profileHollow); + prim.PrimData.ProfileHollow = Primitive.UnpackProfileHollow(profileHollow); // TextureEntry int textureEntryLength = (int)Helpers.BytesToUInt(block.Data, i); i += 4; - prim.Textures = new LLObject.TextureEntry(block.Data, i, textureEntryLength); + prim.Textures = new Primitive.TextureEntry(block.Data, i, textureEntryLength); i += textureEntryLength; // Texture animation @@ -2238,11 +2051,11 @@ namespace OpenMetaverse } /// - /// Handle KillObject packets from the simulator + /// Handle KiPrimitive packets from the simulator /// /// The packet containing the object data /// The simulator sending the data - protected void KillObjectHandler(Packet packet, Simulator simulator) + protected void KiPrimitiveHandler(Packet packet, Simulator simulator) { KillObjectPacket kill = (KillObjectPacket)packet; @@ -2322,15 +2135,16 @@ namespace OpenMetaverse for (int i = 0; i < datablocks.Length; ++i) { ObjectPropertiesPacket.ObjectDataBlock objectData = datablocks[i]; - LLObject.ObjectProperties props = new LLObject.ObjectProperties(); + Primitive.ObjectProperties props = new Primitive.ObjectProperties(); + props.ObjectID = objectData.ObjectID; props.AggregatePerms = objectData.AggregatePerms; props.AggregatePermTextures = objectData.AggregatePermTextures; props.AggregatePermTexturesOwner = objectData.AggregatePermTexturesOwner; props.Permissions = new Permissions(objectData.BaseMask, objectData.EveryoneMask, objectData.GroupMask, objectData.NextOwnerMask, objectData.OwnerMask); - props.Category = objectData.Category; - props.CreationDate = objectData.CreationDate; + props.Category = (ObjectCategory)objectData.Category; + props.CreationDate = Utils.UnixTimeToDateTime((uint)objectData.CreationDate); props.CreatorID = objectData.CreatorID; props.Description = Utils.BytesToString(objectData.Description); props.FolderID = objectData.FolderID; @@ -2340,11 +2154,10 @@ namespace OpenMetaverse props.ItemID = objectData.ItemID; props.LastOwnerID = objectData.LastOwnerID; props.Name = Utils.BytesToString(objectData.Name); - props.ObjectID = objectData.ObjectID; props.OwnerID = objectData.OwnerID; props.OwnershipCost = objectData.OwnershipCost; props.SalePrice = objectData.SalePrice; - props.SaleType = objectData.SaleType; + props.SaleType = (SaleType)objectData.SaleType; props.SitName = Utils.BytesToString(objectData.SitName); props.TouchName = Utils.BytesToString(objectData.TouchName); @@ -2375,19 +2188,20 @@ namespace OpenMetaverse protected void ObjectPropertiesFamilyHandler(Packet p, Simulator sim) { ObjectPropertiesFamilyPacket op = (ObjectPropertiesFamilyPacket)p; - LLObject.ObjectPropertiesFamily props = new LLObject.ObjectPropertiesFamily(); + Primitive.ObjectProperties props = new Primitive.ObjectProperties(); - props.RequestFlags = (LLObject.ObjectPropertiesFamily.RequestFlagsType)op.ObjectData.RequestFlags; - props.Category = op.ObjectData.Category; + ObjectPropertiesRequestType requestType = (ObjectPropertiesRequestType)op.ObjectData.RequestFlags; + + props.ObjectID = op.ObjectData.ObjectID; + props.Category = (ObjectCategory)op.ObjectData.Category; props.Description = Utils.BytesToString(op.ObjectData.Description); props.GroupID = op.ObjectData.GroupID; props.LastOwnerID = op.ObjectData.LastOwnerID; props.Name = Utils.BytesToString(op.ObjectData.Name); - props.ObjectID = op.ObjectData.ObjectID; props.OwnerID = op.ObjectData.OwnerID; props.OwnershipCost = op.ObjectData.OwnershipCost; props.SalePrice = op.ObjectData.SalePrice; - props.SaleType = op.ObjectData.SaleType; + props.SaleType = (SaleType)op.ObjectData.SaleType; props.Permissions.BaseMask = (PermissionMask)op.ObjectData.BaseMask; props.Permissions.EveryoneMask = (PermissionMask)op.ObjectData.EveryoneMask; props.Permissions.GroupMask = (PermissionMask)op.ObjectData.GroupMask; @@ -2397,19 +2211,19 @@ namespace OpenMetaverse if (Client.Settings.OBJECT_TRACKING) { Primitive findPrim = sim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.ID == props.ObjectID; }); + delegate(Primitive prim) { return prim.ID == op.ObjectData.ObjectID; }); if (findPrim != null) { lock (sim.ObjectsPrimitives.Dictionary) { if (sim.ObjectsPrimitives.Dictionary.ContainsKey(findPrim.LocalID)) - sim.ObjectsPrimitives.Dictionary[findPrim.LocalID].PropertiesFamily = props; + sim.ObjectsPrimitives.Dictionary[findPrim.LocalID].Properties.SetFamilyProperties(props); } } } - FireOnObjectPropertiesFamily(sim, props); + FireOnObjectPropertiesFamily(sim, props, requestType); } #endregion Packet Handlers @@ -2420,14 +2234,14 @@ namespace OpenMetaverse /// Setup the ObjectData parameters for a basic wooden cube prim /// /// ObjectData struct representing a basic wooden cube prim - public static LLObject.ObjectData BuildCube() + public static Primitive.ConstructionData BuildCube() { - LLObject.ObjectData prim = new LLObject.ObjectData(); + Primitive.ConstructionData prim = new Primitive.ConstructionData(); prim.PCode = PCode.Prim; - prim.Material = LLObject.MaterialType.Wood; - prim.ProfileCurve = LLObject.ProfileCurve.Square; - prim.PathCurve = LLObject.PathCurve.Line; + prim.Material = Material.Wood; + prim.ProfileCurve = ProfileCurve.Square; + prim.PathCurve = PathCurve.Line; prim.ProfileEnd = 1f; prim.PathEnd = 1f; prim.PathScaleX = 1f; @@ -2447,9 +2261,8 @@ namespace OpenMetaverse protected void SetAvatarSittingOn(Simulator sim, Avatar av, uint localid, uint oldSeatID) { if (av.LocalID == Client.Self.localID) Client.Self.sittingOn = localid; - av.sittingOn = localid; - - + av.ParentID = localid; + if (OnAvatarSitChanged != null && oldSeatID != localid) { try { OnAvatarSitChanged(sim, av, localid, oldSeatID); } @@ -2471,12 +2284,7 @@ namespace OpenMetaverse #region Event Notification - /// - /// - /// - /// - /// - protected void FireOnObjectProperties(Simulator sim, LLObject.ObjectProperties props) + protected void FireOnObjectProperties(Simulator sim, Primitive.ObjectProperties props) { if (OnObjectProperties != null) { @@ -2485,25 +2293,16 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - protected void FireOnObjectPropertiesFamily(Simulator sim, LLObject.ObjectPropertiesFamily props) + protected void FireOnObjectPropertiesFamily(Simulator sim, Primitive.ObjectProperties props, + ObjectPropertiesRequestType type) { if (OnObjectPropertiesFamily != null) { - try { OnObjectPropertiesFamily(sim, props); } + try { OnObjectPropertiesFamily(sim, props, type); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } } - /// - /// - /// - /// - /// protected void FireOnObjectKilled(Simulator simulator, uint localid) { if (OnObjectKilled != null) @@ -2513,13 +2312,6 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - /// - /// protected void FireOnNewPrim(Simulator simulator, Primitive prim, ulong RegionHandle, ushort TimeDilation) { if (OnNewPrim != null) @@ -2529,13 +2321,6 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - /// - /// protected void FireOnNewFoliage(Simulator simulator, Primitive prim, ulong RegionHandle, ushort TimeDilation) { if (OnNewFoliage != null) @@ -2545,13 +2330,6 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - /// - /// protected void FireOnNewAttachment(Simulator simulator, Primitive prim, ulong RegionHandle, ushort TimeDilation) { if (OnNewAttachment != null) @@ -2561,13 +2339,6 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - /// - /// protected void FireOnNewAvatar(Simulator simulator, Avatar avatar, ulong RegionHandle, ushort TimeDilation) { if (OnNewAvatar != null) @@ -2577,13 +2348,6 @@ namespace OpenMetaverse } } - /// - /// - /// - /// - /// - /// - /// protected void FireOnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong RegionHandle, ushort TimeDilation) { if (OnObjectUpdated != null) @@ -2702,7 +2466,7 @@ namespace OpenMetaverse Client.Network.Simulators[i].ObjectsPrimitives.ForEach( delegate(Primitive prim) { - if (prim.Joint == Primitive.JointType.Invalid) + if (prim.Joint == JointType.Invalid) { #region Angular Velocity Vector3 angVel = prim.AngularVelocity; @@ -2730,11 +2494,11 @@ namespace OpenMetaverse } #endregion Linear Motion } - else if (prim.Joint == Primitive.JointType.Hinge) + else if (prim.Joint == JointType.Hinge) { //FIXME: Hinge movement extrapolation } - else if (prim.Joint == Primitive.JointType.Point) + else if (prim.Joint == JointType.Point) { //FIXME: Point movement extrapolation } diff --git a/OpenMetaverse/ParcelManager.cs b/OpenMetaverse/ParcelManager.cs index a56a5357..90465b77 100644 --- a/OpenMetaverse/ParcelManager.cs +++ b/OpenMetaverse/ParcelManager.cs @@ -175,7 +175,7 @@ namespace OpenMetaverse /// objects CreateGroupObjects = 1 << 26, /// Allow all objects to enter this parcel - AllowAllObjectEntry = 1 << 27, + AllowAPrimitiveEntry = 1 << 27, /// Only allow group and owner objects to enter this parcel AllowGroupObjectEntry = 1 << 28, /// Voice Enabled on this parcel diff --git a/OpenMetaverse/Permissions.cs b/OpenMetaverse/Permissions.cs index dd031b55..0e999d7e 100644 --- a/OpenMetaverse/Permissions.cs +++ b/OpenMetaverse/Permissions.cs @@ -95,6 +95,30 @@ namespace OpenMetaverse BaseMask, EveryoneMask, GroupMask, NextOwnerMask, OwnerMask); } - public static Permissions NoPermissions = new Permissions(); + public override bool Equals(object obj) + { + return (obj is Permissions) ? this == (Permissions)obj : false; + } + + public bool Equals(Permissions other) + { + return this == other; + } + + public static bool operator ==(Permissions lhs, Permissions rhs) + { + return (lhs.BaseMask == rhs.BaseMask) && (lhs.EveryoneMask == rhs.EveryoneMask) && + (lhs.GroupMask == rhs.GroupMask) && (lhs.NextOwnerMask == rhs.NextOwnerMask) && + (lhs.OwnerMask == rhs.OwnerMask); + } + + public static bool operator !=(Permissions lhs, Permissions rhs) + { + return !(lhs == rhs); + } + + public static readonly Permissions NoPermissions = new Permissions(); + public static readonly Permissions FullPermissions = new Permissions(UInt32.MaxValue, UInt32.MaxValue, + UInt32.MaxValue, UInt32.MaxValue, UInt32.MaxValue); } } diff --git a/OpenMetaverse/ParticleSystem.cs b/OpenMetaverse/Primitives/ParticleSystem.cs similarity index 96% rename from OpenMetaverse/ParticleSystem.cs rename to OpenMetaverse/Primitives/ParticleSystem.cs index 43b2aa29..8623483a 100644 --- a/OpenMetaverse/ParticleSystem.cs +++ b/OpenMetaverse/Primitives/ParticleSystem.cs @@ -1,282 +1,293 @@ -/* - * Copyright (c) 2007-2008, openmetaverse.org - * All rights reserved. - * - * - 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. - * - Neither the name of the openmetaverse.org 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Generic; -using System.ComponentModel; - -namespace OpenMetaverse -{ - /// - /// Particle system specific enumerators, flags and methods. - /// - public partial class Primitive - { - /// - /// Complete structure for the particle system - /// - public struct ParticleSystem - { - /// - /// Particle source pattern - /// - public enum SourcePattern : byte - { - /// None - None = 0, - /// Drop particles from source position with no force - Drop = 0x01, - /// "Explode" particles in all directions - Explode = 0x02, - /// Particles shoot across a 2D area - Angle = 0x04, - /// Particles shoot across a 3D Cone - AngleCone = 0x08, - /// Inverse of AngleCone (shoot particles everywhere except the 3D cone defined - AngleConeEmpty = 0x10 - } - - /// - /// Particle Data Flags - /// - [Flags] - public enum ParticleDataFlags : uint - { - /// None - None = 0, - /// Interpolate color and alpha from start to end - InterpColor = 0x001, - /// Interpolate scale from start to end - InterpScale = 0x002, - /// Bounce particles off particle sources Z height - Bounce = 0x004, - /// velocity of particles is dampened toward the simulators wind - Wind = 0x008, - /// Particles follow the source - FollowSrc = 0x010, - /// Particles point towards the direction of source's velocity - FollowVelocity = 0x020, - /// Target of the particles - TargetPos = 0x040, - /// Particles are sent in a straight line - TargetLinear = 0x080, - /// Particles emit a glow - Emissive = 0x100, - /// used for point/grab/touch - Beam = 0x200 - } - - /// - /// Particle Flags Enum - /// - [Flags] - public enum ParticleFlags : uint - { - /// None - None = 0, - /// Acceleration and velocity for particles are - /// relative to the object rotation - ObjectRelative = 0x01, - /// Particles use new 'correct' angle parameters - UseNewAngle = 0x02 - } - - - public uint CRC; - /// Particle Flags - /// There appears to be more data packed in to this area - /// for many particle systems. It doesn't appear to be flag values - /// and serialization breaks unless there is a flag for every - /// possible bit so it is left as an unsigned integer - public uint PartFlags; - /// pattern of particles - public SourcePattern Pattern; - /// A representing the maximimum age (in seconds) particle will be displayed - /// Maximum value is 30 seconds - public float MaxAge; - /// A representing the number of seconds, - /// from when the particle source comes into view, - /// or the particle system's creation, that the object will emits particles; - /// after this time period no more particles are emitted - public float StartAge; - /// A in radians that specifies where particles will not be created - public float InnerAngle; - /// A in radians that specifies where particles will be created - public float OuterAngle; - /// A representing the number of seconds between burts. - public float BurstRate; - /// A representing the number of meters - /// around the center of the source where particles will be created. - public float BurstRadius; - /// A representing in seconds, the minimum speed between bursts of new particles - /// being emitted - public float BurstSpeedMin; - /// A representing in seconds the maximum speed of new particles being emitted. - public float BurstSpeedMax; - /// A representing the maximum number of particles emitted per burst - public byte BurstPartCount; - /// A which represents the velocity (speed) from the source which particles are emitted - public Vector3 AngularVelocity; - /// A which represents the Acceleration from the source which particles are emitted - public Vector3 PartAcceleration; - /// The Key of the texture displayed on the particle - public UUID Texture; - /// The Key of the specified target object or avatar particles will follow - public UUID Target; - /// Flags of particle from - public ParticleDataFlags PartDataFlags; - /// Max Age particle system will emit particles for - public float PartMaxAge; - /// The the particle has at the beginning of its lifecycle - public Color4 PartStartColor; - /// The the particle has at the ending of its lifecycle - public Color4 PartEndColor; - /// A that represents the starting X size of the particle - /// Minimum value is 0, maximum value is 4 - public float PartStartScaleX; - /// A that represents the starting Y size of the particle - /// Minimum value is 0, maximum value is 4 - public float PartStartScaleY; - /// A that represents the ending X size of the particle - /// Minimum value is 0, maximum value is 4 - public float PartEndScaleX; - /// A that represents the ending Y size of the particle - /// Minimum value is 0, maximum value is 4 - public float PartEndScaleY; - - /// - /// Decodes a byte[] array into a ParticleSystem Object - /// - /// ParticleSystem object - /// Start position for BitPacker - public ParticleSystem(byte[] data, int pos) - { - // TODO: Not sure exactly how many bytes we need here, so partial - // (truncated) data will cause an exception to be thrown - if (data.Length > 0) - { - BitPack pack = new BitPack(data, pos); - - CRC = pack.UnpackUBits(32); - PartFlags = pack.UnpackUBits(32); - Pattern = (SourcePattern)pack.UnpackByte(); - MaxAge = pack.UnpackFixed(false, 8, 8); - StartAge = pack.UnpackFixed(false, 8, 8); - InnerAngle = pack.UnpackFixed(false, 3, 5); - OuterAngle = pack.UnpackFixed(false, 3, 5); - BurstRate = pack.UnpackFixed(false, 8, 8); - BurstRadius = pack.UnpackFixed(false, 8, 8); - BurstSpeedMin = pack.UnpackFixed(false, 8, 8); - BurstSpeedMax = pack.UnpackFixed(false, 8, 8); - BurstPartCount = pack.UnpackByte(); - float x = pack.UnpackFixed(true, 8, 7); - float y = pack.UnpackFixed(true, 8, 7); - float z = pack.UnpackFixed(true, 8, 7); - AngularVelocity = new Vector3(x, y, z); - x = pack.UnpackFixed(true, 8, 7); - y = pack.UnpackFixed(true, 8, 7); - z = pack.UnpackFixed(true, 8, 7); - PartAcceleration = new Vector3(x, y, z); - Texture = pack.UnpackUUID(); - Target = pack.UnpackUUID(); - - PartDataFlags = (ParticleDataFlags)pack.UnpackUBits(32); - PartMaxAge = pack.UnpackFixed(false, 8, 8); - byte r = pack.UnpackByte(); - byte g = pack.UnpackByte(); - byte b = pack.UnpackByte(); - byte a = pack.UnpackByte(); - PartStartColor = new Color4(r, g, b, a); - r = pack.UnpackByte(); - g = pack.UnpackByte(); - b = pack.UnpackByte(); - a = pack.UnpackByte(); - PartEndColor = new Color4(r, g, b, a); - PartStartScaleX = pack.UnpackFixed(false, 3, 5); - PartStartScaleY = pack.UnpackFixed(false, 3, 5); - PartEndScaleX = pack.UnpackFixed(false, 3, 5); - PartEndScaleY = pack.UnpackFixed(false, 3, 5); - } - else - { - CRC = PartFlags = 0; - Pattern = SourcePattern.None; - MaxAge = StartAge = InnerAngle = OuterAngle = BurstRate = BurstRadius = BurstSpeedMin = - BurstSpeedMax = 0.0f; - BurstPartCount = 0; - AngularVelocity = PartAcceleration = Vector3.Zero; - Texture = Target = UUID.Zero; - PartDataFlags = ParticleDataFlags.None; - PartMaxAge = 0.0f; - PartStartColor = PartEndColor = Color4.Black; - PartStartScaleX = PartStartScaleY = PartEndScaleX = PartEndScaleY = 0.0f; - } - } - - /// - /// Generate byte[] array from particle data - /// - /// Byte array - public byte[] GetBytes() - { - byte[] bytes = new byte[86]; - BitPack pack = new BitPack(bytes, 0); - - pack.PackBits(CRC, 32); - pack.PackBits((uint)PartFlags, 32); - pack.PackBits((uint)Pattern, 8); - pack.PackFixed(MaxAge, false, 8, 8); - pack.PackFixed(StartAge, false, 8, 8); - pack.PackFixed(InnerAngle, false, 3, 5); - pack.PackFixed(OuterAngle, false, 3, 5); - pack.PackFixed(BurstRate, false, 8, 8); - pack.PackFixed(BurstRadius, false, 8, 8); - pack.PackFixed(BurstSpeedMin, false, 8, 8); - pack.PackFixed(BurstSpeedMax, false, 8, 8); - pack.PackBits(BurstPartCount, 8); - pack.PackFixed(AngularVelocity.X, true, 8, 7); - pack.PackFixed(AngularVelocity.Y, true, 8, 7); - pack.PackFixed(AngularVelocity.Z, true, 8, 7); - pack.PackFixed(PartAcceleration.X, true, 8, 7); - pack.PackFixed(PartAcceleration.Y, true, 8, 7); - pack.PackFixed(PartAcceleration.Z, true, 8, 7); - pack.PackUUID(Texture); - pack.PackUUID(Target); - - pack.PackBits((uint)PartDataFlags, 32); - pack.PackFixed(PartMaxAge, false, 8, 8); - pack.PackColor(PartStartColor); - pack.PackColor(PartEndColor); - pack.PackFixed(PartStartScaleX, false, 3, 5); - pack.PackFixed(PartStartScaleY, false, 3, 5); - pack.PackFixed(PartEndScaleX, false, 3, 5); - pack.PackFixed(PartEndScaleY, false, 3, 5); - - return bytes; - } - } - } -} +/* + * Copyright (c) 2007-2008, openmetaverse.org + * All rights reserved. + * + * - 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. + * - Neither the name of the openmetaverse.org 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Generic; +using System.ComponentModel; + +namespace OpenMetaverse +{ + /// + /// Particle system specific enumerators, flags and methods. + /// + public partial class Primitive + { + #region Subclasses + + /// + /// Complete structure for the particle system + /// + public struct ParticleSystem + { + /// + /// Particle source pattern + /// + public enum SourcePattern : byte + { + /// None + None = 0, + /// Drop particles from source position with no force + Drop = 0x01, + /// "Explode" particles in all directions + Explode = 0x02, + /// Particles shoot across a 2D area + Angle = 0x04, + /// Particles shoot across a 3D Cone + AngleCone = 0x08, + /// Inverse of AngleCone (shoot particles everywhere except the 3D cone defined + AngleConeEmpty = 0x10 + } + + /// + /// Particle Data Flags + /// + [Flags] + public enum ParticleDataFlags : uint + { + /// None + None = 0, + /// Interpolate color and alpha from start to end + InterpColor = 0x001, + /// Interpolate scale from start to end + InterpScale = 0x002, + /// Bounce particles off particle sources Z height + Bounce = 0x004, + /// velocity of particles is dampened toward the simulators wind + Wind = 0x008, + /// Particles follow the source + FollowSrc = 0x010, + /// Particles point towards the direction of source's velocity + FollowVelocity = 0x020, + /// Target of the particles + TargetPos = 0x040, + /// Particles are sent in a straight line + TargetLinear = 0x080, + /// Particles emit a glow + Emissive = 0x100, + /// used for point/grab/touch + Beam = 0x200 + } + + /// + /// Particle Flags Enum + /// + [Flags] + public enum ParticleFlags : uint + { + /// None + None = 0, + /// Acceleration and velocity for particles are + /// relative to the object rotation + ObjectRelative = 0x01, + /// Particles use new 'correct' angle parameters + UseNewAngle = 0x02 + } + + + public uint CRC; + /// Particle Flags + /// There appears to be more data packed in to this area + /// for many particle systems. It doesn't appear to be flag values + /// and serialization breaks unless there is a flag for every + /// possible bit so it is left as an unsigned integer + public uint PartFlags; + /// pattern of particles + public SourcePattern Pattern; + /// A representing the maximimum age (in seconds) particle will be displayed + /// Maximum value is 30 seconds + public float MaxAge; + /// A representing the number of seconds, + /// from when the particle source comes into view, + /// or the particle system's creation, that the object will emits particles; + /// after this time period no more particles are emitted + public float StartAge; + /// A in radians that specifies where particles will not be created + public float InnerAngle; + /// A in radians that specifies where particles will be created + public float OuterAngle; + /// A representing the number of seconds between burts. + public float BurstRate; + /// A representing the number of meters + /// around the center of the source where particles will be created. + public float BurstRadius; + /// A representing in seconds, the minimum speed between bursts of new particles + /// being emitted + public float BurstSpeedMin; + /// A representing in seconds the maximum speed of new particles being emitted. + public float BurstSpeedMax; + /// A representing the maximum number of particles emitted per burst + public byte BurstPartCount; + /// A which represents the velocity (speed) from the source which particles are emitted + public Vector3 AngularVelocity; + /// A which represents the Acceleration from the source which particles are emitted + public Vector3 PartAcceleration; + /// The Key of the texture displayed on the particle + public UUID Texture; + /// The Key of the specified target object or avatar particles will follow + public UUID Target; + /// Flags of particle from + public ParticleDataFlags PartDataFlags; + /// Max Age particle system will emit particles for + public float PartMaxAge; + /// The the particle has at the beginning of its lifecycle + public Color4 PartStartColor; + /// The the particle has at the ending of its lifecycle + public Color4 PartEndColor; + /// A that represents the starting X size of the particle + /// Minimum value is 0, maximum value is 4 + public float PartStartScaleX; + /// A that represents the starting Y size of the particle + /// Minimum value is 0, maximum value is 4 + public float PartStartScaleY; + /// A that represents the ending X size of the particle + /// Minimum value is 0, maximum value is 4 + public float PartEndScaleX; + /// A that represents the ending Y size of the particle + /// Minimum value is 0, maximum value is 4 + public float PartEndScaleY; + + /// + /// Decodes a byte[] array into a ParticleSystem Object + /// + /// ParticleSystem object + /// Start position for BitPacker + public ParticleSystem(byte[] data, int pos) + { + // TODO: Not sure exactly how many bytes we need here, so partial + // (truncated) data will cause an exception to be thrown + if (data.Length > 0) + { + BitPack pack = new BitPack(data, pos); + + CRC = pack.UnpackUBits(32); + PartFlags = pack.UnpackUBits(32); + Pattern = (SourcePattern)pack.UnpackByte(); + MaxAge = pack.UnpackFixed(false, 8, 8); + StartAge = pack.UnpackFixed(false, 8, 8); + InnerAngle = pack.UnpackFixed(false, 3, 5); + OuterAngle = pack.UnpackFixed(false, 3, 5); + BurstRate = pack.UnpackFixed(false, 8, 8); + BurstRadius = pack.UnpackFixed(false, 8, 8); + BurstSpeedMin = pack.UnpackFixed(false, 8, 8); + BurstSpeedMax = pack.UnpackFixed(false, 8, 8); + BurstPartCount = pack.UnpackByte(); + float x = pack.UnpackFixed(true, 8, 7); + float y = pack.UnpackFixed(true, 8, 7); + float z = pack.UnpackFixed(true, 8, 7); + AngularVelocity = new Vector3(x, y, z); + x = pack.UnpackFixed(true, 8, 7); + y = pack.UnpackFixed(true, 8, 7); + z = pack.UnpackFixed(true, 8, 7); + PartAcceleration = new Vector3(x, y, z); + Texture = pack.UnpackUUID(); + Target = pack.UnpackUUID(); + + PartDataFlags = (ParticleDataFlags)pack.UnpackUBits(32); + PartMaxAge = pack.UnpackFixed(false, 8, 8); + byte r = pack.UnpackByte(); + byte g = pack.UnpackByte(); + byte b = pack.UnpackByte(); + byte a = pack.UnpackByte(); + PartStartColor = new Color4(r, g, b, a); + r = pack.UnpackByte(); + g = pack.UnpackByte(); + b = pack.UnpackByte(); + a = pack.UnpackByte(); + PartEndColor = new Color4(r, g, b, a); + PartStartScaleX = pack.UnpackFixed(false, 3, 5); + PartStartScaleY = pack.UnpackFixed(false, 3, 5); + PartEndScaleX = pack.UnpackFixed(false, 3, 5); + PartEndScaleY = pack.UnpackFixed(false, 3, 5); + } + else + { + CRC = PartFlags = 0; + Pattern = SourcePattern.None; + MaxAge = StartAge = InnerAngle = OuterAngle = BurstRate = BurstRadius = BurstSpeedMin = + BurstSpeedMax = 0.0f; + BurstPartCount = 0; + AngularVelocity = PartAcceleration = Vector3.Zero; + Texture = Target = UUID.Zero; + PartDataFlags = ParticleDataFlags.None; + PartMaxAge = 0.0f; + PartStartColor = PartEndColor = Color4.Black; + PartStartScaleX = PartStartScaleY = PartEndScaleX = PartEndScaleY = 0.0f; + } + } + + /// + /// Generate byte[] array from particle data + /// + /// Byte array + public byte[] GetBytes() + { + byte[] bytes = new byte[86]; + BitPack pack = new BitPack(bytes, 0); + + pack.PackBits(CRC, 32); + pack.PackBits((uint)PartFlags, 32); + pack.PackBits((uint)Pattern, 8); + pack.PackFixed(MaxAge, false, 8, 8); + pack.PackFixed(StartAge, false, 8, 8); + pack.PackFixed(InnerAngle, false, 3, 5); + pack.PackFixed(OuterAngle, false, 3, 5); + pack.PackFixed(BurstRate, false, 8, 8); + pack.PackFixed(BurstRadius, false, 8, 8); + pack.PackFixed(BurstSpeedMin, false, 8, 8); + pack.PackFixed(BurstSpeedMax, false, 8, 8); + pack.PackBits(BurstPartCount, 8); + pack.PackFixed(AngularVelocity.X, true, 8, 7); + pack.PackFixed(AngularVelocity.Y, true, 8, 7); + pack.PackFixed(AngularVelocity.Z, true, 8, 7); + pack.PackFixed(PartAcceleration.X, true, 8, 7); + pack.PackFixed(PartAcceleration.Y, true, 8, 7); + pack.PackFixed(PartAcceleration.Z, true, 8, 7); + pack.PackUUID(Texture); + pack.PackUUID(Target); + + pack.PackBits((uint)PartDataFlags, 32); + pack.PackFixed(PartMaxAge, false, 8, 8); + pack.PackColor(PartStartColor); + pack.PackColor(PartEndColor); + pack.PackFixed(PartStartScaleX, false, 3, 5); + pack.PackFixed(PartStartScaleY, false, 3, 5); + pack.PackFixed(PartEndScaleX, false, 3, 5); + pack.PackFixed(PartEndScaleY, false, 3, 5); + + return bytes; + } + } + + #endregion Subclasses + + #region Public Members + + /// + public ParticleSystem ParticleSys; + + #endregion Public Members + } +} diff --git a/OpenMetaverse/Primitives/Primitive.cs b/OpenMetaverse/Primitives/Primitive.cs new file mode 100644 index 00000000..f5fb2632 --- /dev/null +++ b/OpenMetaverse/Primitives/Primitive.cs @@ -0,0 +1,1381 @@ +/* + * Copyright (c) 2006-2008, openmetaverse.org + * All rights reserved. + * + * - 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. + * - Neither the name of the openmetaverse.org 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Generic; +using OpenMetaverse.StructuredData; + +namespace OpenMetaverse +{ + #region Enums + + /// + /// Identifier code for primitive types + /// + public enum PCode : byte + { + /// None + None = 0, + /// A Primitive + Prim = 9, + /// A Avatar + Avatar = 47, + /// Linden grass + Grass = 95, + /// Linden tree + NewTree = 111, + /// A primitive that acts as the source for a particle stream + ParticleSystem = 143, + /// A Linden tree + Tree = 255 + } + + /// + /// Primary parameters for primitives such as Physics Enabled or Phantom + /// + [Flags] + public enum PrimFlags : uint + { + /// Whether physics are enabled for this object + Physics = 0x00000001, + /// + CreateSelected = 0x00000002, + /// + ObjectModify = 0x00000004, + /// + ObjectCopy = 0x00000008, + /// + ObjectAnyOwner = 0x00000010, + /// + ObjectYouOwner = 0x00000020, + /// + Scripted = 0x00000040, + /// Whether this object contains an active touch script + Touch = 0x00000080, + /// + ObjectMove = 0x00000100, + /// Whether this object can receive payments + Money = 0x00000200, + /// Whether this object is phantom (no collisions) + Phantom = 0x00000400, + /// + InventoryEmpty = 0x00000800, + /// + JointHinge = 0x00001000, + /// + JointP2P = 0x00002000, + /// + JointLP2P = 0x00004000, + /// Deprecated + JointWheel = 0x00008000, + /// + AllowInventoryDrop = 0x00010000, + /// + ObjectTransfer = 0x00020000, + /// + ObjectGroupOwned = 0x00040000, + /// Deprecated + ObjectYouOfficer = 0x00080000, + /// + CameraDecoupled = 0x00100000, + /// + AnimSource = 0x00200000, + /// + CameraSource = 0x00400000, + /// + CastShadows = 0x00800000, + /// + ObjectOwnerModify = 0x10000000, + /// + TemporaryOnRez = 0x20000000, + /// + Temporary = 0x40000000, + /// + ZlibCompressed = 0x80000000 + } + + public enum ProfileCurve : byte + { + Circle = 0x00, + Square = 0x01, + IsoTriangle = 0x02, + EqualTriangle = 0x03, + RightTriangle = 0x04, + HalfCircle = 0x05 + } + + public enum HoleType : byte + { + Same = 0x00, + Circle = 0x10, + Square = 0x20, + Triangle = 0x30 + } + + public enum PathCurve : byte + { + Line = 0x10, + Circle = 0x20, + Circle2 = 0x30, + Test = 0x40, + Flexible = 0x80 + } + + /// + /// Material type for a primitive + /// + public enum Material : byte + { + /// + Stone = 0, + /// + Metal, + /// + Glass, + /// + Wood, + /// + Flesh, + /// + Plastic, + /// + Rubber, + /// + Light + } + + /// + /// Used in a helper function to roughly determine prim shape + /// + public enum PrimType + { + Unknown, + Box, + Cylinder, + Prism, + Sphere, + Torus, + Tube, + Ring, + Sculpt + } + + /// + /// Extra parameters for primitives, these flags are for features that have + /// been added after the original ObjectFlags that has all eight bits + /// reserved already + /// + [Flags] + public enum ExtraParamType : ushort + { + /// Whether this object has flexible parameters + Flexible = 0x10, + /// Whether this object has light parameters + Light = 0x20, + /// Whether this object is a sculpted prim + Sculpt = 0x30 + } + + /// + /// + /// + public enum JointType : byte + { + /// + Invalid = 0, + /// + Hinge = 1, + /// + Point = 2, + // + //[Obsolete] + //LPoint = 3, + //[Obsolete] + //Wheel = 4 + } + + /// + /// + /// + public enum SculptType : byte + { + /// + None = 0, + /// + Sphere = 1, + /// + Torus = 2, + /// + Plane = 3, + /// + Cylinder = 4 + } + + /// + /// + /// + public enum FaceType : ushort + { + /// + PathBegin = 0x1 << 0, + /// + PathEnd = 0x1 << 1, + /// + InnerSide = 0x1 << 2, + /// + ProfileBegin = 0x1 << 3, + /// + ProfileEnd = 0x1 << 4, + /// + OuterSide0 = 0x1 << 5, + /// + OuterSide1 = 0x1 << 6, + /// + OuterSide2 = 0x1 << 7, + /// + OuterSide3 = 0x1 << 8 + } + + /// + /// + /// + public enum ObjectCategory + { + /// + Invalid = -1, + /// + None = 0, + /// + Owner, + /// + Group, + /// + Other, + /// + Selectected, + /// + Temporary + } + + /// + /// Attachment points for objects on avatar bodies + /// + /// + /// Both InventoryObject and InventoryAttachment types can be attached + /// + public enum AttachmentPoint : byte + { + /// Right hand if object was not previously attached + Default = 0, + /// Chest + Chest = 1, + /// Skull + Skull, + /// Left shoulder + LeftShoulder, + /// Right shoulder + RightShoulder, + /// Left hand + LeftHand, + /// Right hand + RightHand, + /// Left foot + LeftFoot, + /// Right foot + RightFoot, + /// Spine + Spine, + /// Pelvis + Pelvis, + /// Mouth + Mouth, + /// Chin + Chin, + /// Left ear + LeftEar, + /// Right ear + RightEar, + /// Left eyeball + LeftEyeball, + /// Right eyeball + RightEyeball, + /// Nose + Nose, + /// Right upper arm + RightUpperArm, + /// Right forearm + RightForearm, + /// Left upper arm + LeftUpperArm, + /// Left forearm + LeftForearm, + /// Right hip + RightHip, + /// Right upper leg + RightUpperLeg, + /// Right lower leg + RightLowerLeg, + /// Left hip + LeftHip, + /// Left upper leg + LeftUpperLeg, + /// Left lower leg + LeftLowerLeg, + /// Stomach + Stomach, + /// Left pectoral + LeftPec, + /// Right pectoral + RightPec, + /// HUD Center position 2 + HUDCenter2, + /// HUD Top-right + HUDTopRight, + /// HUD Top + HUDTop, + /// HUD Top-left + HUDTopLeft, + /// HUD Center + HUDCenter, + /// HUD Bottom-left + HUDBottomLeft, + /// HUD Bottom + HUDBottom, + /// HUD Bottom-right + HUDBottomRight + } + + /// + /// Tree foliage types + /// + public enum Tree : byte + { + /// Pine1 tree + Pine1 = 0, + /// Oak tree + Oak, + /// Tropical Bush1 + TropicalBush1, + /// Palm1 tree + Palm1, + /// Dogwood tree + Dogwood, + /// Tropical Bush2 + TropicalBush2, + /// Palm2 tree + Palm2, + /// Cypress1 tree + Cypress1, + /// Cypress2 tree + Cypress2, + /// Pine2 tree + Pine2, + /// Plumeria + Plumeria, + /// Winter pinetree1 + WinterPine1, + /// Winter Aspen tree + WinterAspen, + /// Winter pinetree2 + WinterPine2, + /// Eucalyptus tree + Eucalyptus, + /// Fern + Fern, + /// Eelgrass + Eelgrass, + /// Sea Sword + SeaSword, + /// Kelp1 plant + Kelp1, + /// Beach grass + BeachGrass1, + /// Kelp2 plant + Kelp2 + } + + /// + /// Grass foliage types + /// + public enum Grass : byte + { + /// + Grass0 = 0, + /// + Grass1, + /// + Grass2, + /// + Grass3, + /// + Grass4, + /// + Undergrowth1 + } + + /// + /// Action associated with clicking on an object + /// + public enum ClickAction : byte + { + /// Touch object + Touch = 0, + /// Sit on object + Sit = 1, + /// Purchase object or contents + Buy = 2, + /// Pay the object + Pay = 3, + /// Open task inventory + OpenTask = 4, + /// Play parcel media + PlayMedia = 5, + /// Open parcel media + OpenMedia = 6 + } + + #endregion Enums + + public partial class Primitive : IEquatable + { + // Used for packing and unpacking parameters + protected const float CUT_QUANTA = 0.00002f; + protected const float SCALE_QUANTA = 0.01f; + protected const float SHEAR_QUANTA = 0.01f; + protected const float TAPER_QUANTA = 0.01f; + protected const float REV_QUANTA = 0.015f; + protected const float HOLLOW_QUANTA = 0.00002f; + + #region Subclasses + + /// + /// Parameters used to construct a visual representation of a primitive + /// + public struct ConstructionData + { + private const byte PROFILE_MASK = 0x0F; + private const byte HOLE_MASK = 0xF0; + + /// + internal byte profileCurve; + + /// + public PathCurve PathCurve; + /// + public float PathEnd; + /// + public float PathRadiusOffset; + /// + public float PathSkew; + /// + public float PathScaleX; + /// + public float PathScaleY; + /// + public float PathShearX; + /// + public float PathShearY; + /// + public float PathTaperX; + /// + public float PathTaperY; + /// + public float PathBegin; + /// + public float PathTwist; + /// + public float PathTwistBegin; + /// + public float PathRevolutions; + /// + public float ProfileBegin; + /// + public float ProfileEnd; + /// + public float ProfileHollow; + + /// + public Material Material; + /// + public byte State; + /// + public PCode PCode; + + #region Properties + + /// + public ProfileCurve ProfileCurve + { + get { return (ProfileCurve)(profileCurve & PROFILE_MASK); } + set + { + profileCurve &= HOLE_MASK; + profileCurve |= (byte)value; + } + } + + /// + public HoleType ProfileHole + { + get { return (HoleType)(profileCurve & HOLE_MASK); } + set + { + profileCurve &= PROFILE_MASK; + profileCurve |= (byte)value; + } + } + + /// + public Vector2 PathBeginScale + { + get + { + Vector2 begin = new Vector2(1f, 1f); + if (PathScaleX > 1f) + begin.X = 2f - PathScaleX; + if (PathScaleY > 1f) + begin.Y = 2f - PathScaleY; + return begin; + } + } + + /// + public Vector2 PathEndScale + { + get + { + Vector2 end = new Vector2(1f, 1f); + if (PathScaleX < 1f) + end.X = PathScaleX; + if (PathScaleY < 1f) + end.Y = PathScaleY; + return end; + } + } + + /// Uses basic heuristics to estimate the primitive shape + public PrimType Type + { + get + { + bool linearPath = (PathCurve == PathCurve.Line || PathCurve == PathCurve.Flexible); + float scaleX = PathScaleX; + float scaleY = PathScaleY; + + if (linearPath) + { + switch (ProfileCurve) + { + case ProfileCurve.Circle: + return PrimType.Cylinder; + case ProfileCurve.Square: + return PrimType.Box; + case ProfileCurve.IsoTriangle: + case ProfileCurve.EqualTriangle: + case ProfileCurve.RightTriangle: + return PrimType.Prism; + case ProfileCurve.HalfCircle: + default: + return PrimType.Unknown; + } + } + else + { + switch (PathCurve) + { + case PathCurve.Flexible: + return PrimType.Unknown; + case PathCurve.Circle: + switch (ProfileCurve) + { + case ProfileCurve.Circle: + if (scaleY > 0.75f) + return PrimType.Sphere; + else + return PrimType.Torus; + case ProfileCurve.HalfCircle: + return PrimType.Sphere; + case ProfileCurve.EqualTriangle: + return PrimType.Ring; + case ProfileCurve.Square: + if (scaleY <= 0.75f) + return PrimType.Tube; + else + return PrimType.Unknown; + default: + return PrimType.Unknown; + } + case PathCurve.Circle2: + if (ProfileCurve == ProfileCurve.Circle) + return PrimType.Sphere; + else + return PrimType.Unknown; + default: + return PrimType.Unknown; + } + } + } + } + + #endregion Properties + + public override string ToString() + { + return Type.ToString(); + } + } + + /// + /// Information on the flexible properties of a primitive + /// + public struct FlexibleData + { + /// + public int Softness; + /// + public float Gravity; + /// + public float Drag; + /// + public float Wind; + /// + public float Tension; + /// + public Vector3 Force; + + /// + /// + /// + /// + /// + public FlexibleData(byte[] data, int pos) + { + if (data.Length >= 5) + { + Softness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7); + + Tension = (float)(data[pos++] & 0x7F) / 10.0f; + Drag = (float)(data[pos++] & 0x7F) / 10.0f; + Gravity = (float)(data[pos++] / 10.0f) - 10.0f; + Wind = (float)data[pos++] / 10.0f; + Force = new Vector3(data, pos); + } + else + { + Softness = 0; + + Tension = 0.0f; + Drag = 0.0f; + Gravity = 0.0f; + Wind = 0.0f; + Force = Vector3.Zero; + } + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] data = new byte[16]; + int i = 0; + + // Softness is packed in the upper bits of tension and drag + data[i] = (byte)((Softness & 2) << 6); + data[i + 1] = (byte)((Softness & 1) << 7); + + data[i++] |= (byte)((byte)(Tension * 10.01f) & 0x7F); + data[i++] |= (byte)((byte)(Drag * 10.01f) & 0x7F); + data[i++] = (byte)((Gravity + 10.0f) * 10.01f); + data[i++] = (byte)(Wind * 10.01f); + + Force.GetBytes().CopyTo(data, i); + + return data; + } + + /// + /// + /// + /// + public LLSD GetLLSD() + { + LLSDMap map = new LLSDMap(); + + map["simulate_lod"] = LLSD.FromInteger(Softness); + map["gravity"] = LLSD.FromReal(Gravity); + map["air_friction"] = LLSD.FromReal(Drag); + map["wind_sensitivity"] = LLSD.FromReal(Wind); + map["tension"] = LLSD.FromReal(Tension); + map["user_force"] = LLSD.FromVector3(Force); + + return map; + } + + public static FlexibleData FromLLSD(LLSD llsd) + { + FlexibleData flex = new FlexibleData(); + + if (llsd.Type == LLSDType.Map) + { + LLSDMap map = (LLSDMap)llsd; + + flex.Softness = map["simulate_lod"].AsInteger(); + flex.Gravity = (float)map["gravity"].AsReal(); + flex.Drag = (float)map["air_friction"].AsReal(); + flex.Wind = (float)map["wind_sensitivity"].AsReal(); + flex.Tension = (float)map["tension"].AsReal(); + flex.Force = ((LLSDArray)map["user_force"]).AsVector3(); + } + + return flex; + } + } + + /// + /// Information on the light properties of a primitive + /// + public struct LightData + { + /// + public Color4 Color; + /// + public float Intensity; + /// + public float Radius; + /// + public float Cutoff; + /// + public float Falloff; + + /// + /// + /// + /// + /// + public LightData(byte[] data, int pos) + { + if (data.Length - pos >= 16) + { + Color = new Color4(data, pos, false); + Radius = Helpers.BytesToFloat(data, pos + 4); + Cutoff = Helpers.BytesToFloat(data, pos + 8); + Falloff = Helpers.BytesToFloat(data, pos + 12); + + // Alpha in color is actually intensity + Intensity = Color.A; + Color.A = 1f; + } + else + { + Color = Color4.Black; + Radius = 0f; + Cutoff = 0f; + Falloff = 0f; + Intensity = 0f; + } + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] data = new byte[16]; + + // Alpha channel in color is intensity + Color4 tmpColor = Color; + tmpColor.A = Intensity; + tmpColor.GetBytes().CopyTo(data, 0); + Helpers.FloatToBytes(Radius).CopyTo(data, 4); + Helpers.FloatToBytes(Cutoff).CopyTo(data, 8); + Helpers.FloatToBytes(Falloff).CopyTo(data, 12); + + return data; + } + + public LLSD GetLLSD() + { + LLSDMap map = new LLSDMap(); + + map["color"] = LLSD.FromColor4(Color); + map["intensity"] = LLSD.FromReal(Intensity); + map["radius"] = LLSD.FromReal(Radius); + map["cutoff"] = LLSD.FromReal(Cutoff); + map["falloff"] = LLSD.FromReal(Falloff); + + return map; + } + + public static LightData FromLLSD(LLSD llsd) + { + LightData light = new LightData(); + + if (llsd.Type == LLSDType.Map) + { + LLSDMap map = (LLSDMap)llsd; + + light.Color = ((LLSDArray)map["color"]).AsColor4(); + light.Intensity = (float)map["intensity"].AsReal(); + light.Radius = (float)map["radius"].AsReal(); + light.Cutoff = (float)map["cutoff"].AsReal(); + light.Falloff = (float)map["falloff"].AsReal(); + } + + return light; + } + + /// + /// + /// + /// + public override string ToString() + { + return String.Format("Color: {0} Intensity: {1} Radius: {2} Cutoff: {3} Falloff: {4}", + Color, Intensity, Radius, Cutoff, Falloff); + } + } + + /// + /// Information on the sculpt properties of a sculpted primitive + /// + public struct SculptData + { + public UUID SculptTexture; + public SculptType Type; + + public SculptData(byte[] data, int pos) + { + if (data.Length >= 17) + { + SculptTexture = new UUID(data, pos); + Type = (SculptType)data[pos + 16]; + } + else + { + SculptTexture = UUID.Zero; + Type = SculptType.None; + } + } + + public byte[] GetBytes() + { + byte[] data = new byte[17]; + + SculptTexture.GetBytes().CopyTo(data, 0); + data[16] = (byte)Type; + + return data; + } + + public LLSD GetLLSD() + { + LLSDMap map = new LLSDMap(); + + map["texture"] = LLSD.FromUUID(SculptTexture); + map["type"] = LLSD.FromInteger((int)Type); + + return map; + } + + public static SculptData FromLLSD(LLSD llsd) + { + SculptData sculpt = new SculptData(); + + if (llsd.Type == LLSDType.Map) + { + LLSDMap map = (LLSDMap)llsd; + + sculpt.SculptTexture = map["texture"].AsUUID(); + sculpt.Type = (SculptType)map["type"].AsInteger(); + } + + return sculpt; + } + } + + /// + /// Extended properties to describe an object + /// + public struct ObjectProperties + { + /// + public UUID ObjectID; + /// + public UUID CreatorID; + /// + public UUID OwnerID; + /// + public UUID GroupID; + /// + public DateTime CreationDate; + /// + public Permissions Permissions; + /// + public int OwnershipCost; + /// + public SaleType SaleType; + /// + public int SalePrice; + /// + public byte AggregatePerms; + /// + public byte AggregatePermTextures; + /// + public byte AggregatePermTexturesOwner; + /// + public ObjectCategory Category; + /// + public short InventorySerial; + /// + public UUID ItemID; + /// + public UUID FolderID; + /// + public UUID FromTaskID; + /// + public UUID LastOwnerID; + /// + public string Name; + /// + public string Description; + /// + public string TouchName; + /// + public string SitName; + /// + public UUID[] TextureIDs; + + /// + /// Set the properties that are set in an ObjectPropertiesFamily packet + /// + /// that has + /// been partially filled by an ObjectPropertiesFamily packet + public void SetFamilyProperties(ObjectProperties props) + { + ObjectID = props.ObjectID; + OwnerID = props.OwnerID; + GroupID = props.GroupID; + Permissions = props.Permissions; + OwnershipCost = props.OwnershipCost; + SaleType = props.SaleType; + SalePrice = props.SalePrice; + Category = props.Category; + LastOwnerID = props.LastOwnerID; + Name = props.Name; + Description = props.Description; + } + } + + #endregion Subclasses + + #region Public Members + + /// + public UUID ID; + /// + public UUID GroupID; + /// + public uint LocalID; + /// + public uint ParentID; + /// + public ulong RegionHandle; + /// + public PrimFlags Flags; + /// Unknown + public byte[] GenericData; + /// + public Vector3 Position; + /// + public Vector3 Scale; + /// + public Quaternion Rotation; + /// + public Vector3 Velocity; + /// + public Vector3 AngularVelocity; + /// + public Vector3 Acceleration; + /// + public Vector4 CollisionPlane; + /// + public FlexibleData Flexible; + /// + public LightData Light; + /// + public SculptData Sculpt; + /// + public ClickAction ClickAction; + /// + public UUID Sound; + /// Identifies the owner if audio or a particle system is + /// active + public UUID OwnerID; + /// + public byte SoundFlags; + /// + public float SoundGain; + /// + public float SoundRadius; + /// + public string Text = String.Empty; + /// + public Color4 TextColor; + /// + public string MediaURL = String.Empty; + /// + public JointType Joint; + /// + public Vector3 JointPivot; + /// + public Vector3 JointAxisOrAnchor; + /// + public NameValue[] NameValues; + /// + public ConstructionData PrimData; + /// + public ObjectProperties Properties; + + #endregion Public Members + + #region Constructors + + /// + /// Default constructor + /// + public Primitive() + { + } + + #endregion Constructors + + #region Public Methods + + public LLSD GetLLSD() + { + LLSDMap path = new LLSDMap(14); + path["begin"] = LLSD.FromReal(PrimData.PathBegin); + path["curve"] = LLSD.FromInteger((int)PrimData.PathCurve); + path["end"] = LLSD.FromReal(PrimData.PathEnd); + path["radius_offset"] = LLSD.FromReal(PrimData.PathRadiusOffset); + path["revolutions"] = LLSD.FromReal(PrimData.PathRevolutions); + path["scale_x"] = LLSD.FromReal(PrimData.PathScaleX); + path["scale_y"] = LLSD.FromReal(PrimData.PathScaleY); + path["shear_x"] = LLSD.FromReal(PrimData.PathShearX); + path["shear_y"] = LLSD.FromReal(PrimData.PathShearY); + path["skew"] = LLSD.FromReal(PrimData.PathSkew); + path["taper_x"] = LLSD.FromReal(PrimData.PathTaperX); + path["taper_y"] = LLSD.FromReal(PrimData.PathTaperY); + path["twist"] = LLSD.FromReal(PrimData.PathTwist); + path["twist_begin"] = LLSD.FromReal(PrimData.PathTwistBegin); + + LLSDMap profile = new LLSDMap(4); + profile["begin"] = LLSD.FromReal(PrimData.ProfileBegin); + profile["curve"] = LLSD.FromInteger((int)PrimData.ProfileCurve); + profile["hole"] = LLSD.FromInteger((int)PrimData.ProfileHole); + profile["end"] = LLSD.FromReal(PrimData.ProfileEnd); + profile["hollow"] = LLSD.FromReal(PrimData.ProfileHollow); + + LLSDMap volume = new LLSDMap(2); + volume["path"] = path; + volume["profile"] = profile; + + LLSDMap prim = new LLSDMap(9); + prim["name"] = LLSD.FromString(Properties.Name); + prim["description"] = LLSD.FromString(Properties.Description); + prim["phantom"] = LLSD.FromBoolean(((Flags & PrimFlags.Phantom) != 0)); + prim["physical"] = LLSD.FromBoolean(((Flags & PrimFlags.Physics) != 0)); + prim["position"] = LLSD.FromVector3(Position); + prim["rotation"] = LLSD.FromQuaternion(Rotation); + prim["scale"] = LLSD.FromVector3(Scale); + prim["material"] = LLSD.FromInteger((int)PrimData.Material); + prim["shadows"] = LLSD.FromBoolean(((Flags & PrimFlags.CastShadows) != 0)); + prim["textures"] = Textures.GetLLSD(); + prim["volume"] = volume; + if (ParentID != 0) + prim["parentid"] = LLSD.FromInteger(ParentID); + + prim["light"] = Light.GetLLSD(); + prim["flex"] = Flexible.GetLLSD(); + prim["sculpt"] = Sculpt.GetLLSD(); + + return prim; + } + + public static Primitive FromLLSD(LLSD llsd) + { + Primitive prim = new Primitive(); + Primitive.ConstructionData data; + + LLSDMap map = (LLSDMap)llsd; + LLSDMap volume = (LLSDMap)map["volume"]; + LLSDMap path = (LLSDMap)volume["path"]; + LLSDMap profile = (LLSDMap)volume["profile"]; + + #region Path/Profile + + data.profileCurve = (byte)0; + data.State = 0; + data.Material = (Material)map["material"].AsInteger(); + data.PCode = PCode.Prim; // TODO: Put this in LLSD + + data.PathBegin = (float)path["begin"].AsReal(); + data.PathCurve = (PathCurve)path["curve"].AsInteger(); + data.PathEnd = (float)path["end"].AsReal(); + data.PathRadiusOffset = (float)path["radius_offset"].AsReal(); + data.PathRevolutions = (float)path["revolutions"].AsReal(); + data.PathScaleX = (float)path["scale_x"].AsReal(); + data.PathScaleY = (float)path["scale_y"].AsReal(); + data.PathShearX = (float)path["shear_x"].AsReal(); + data.PathShearY = (float)path["shear_y"].AsReal(); + data.PathSkew = (float)path["skew"].AsReal(); + data.PathTaperX = (float)path["taper_x"].AsReal(); + data.PathTaperY = (float)path["taper_y"].AsReal(); + data.PathTwist = (float)path["twist"].AsReal(); + data.PathTwistBegin = (float)path["twist_begin"].AsReal(); + + data.ProfileBegin = (float)profile["begin"].AsReal(); + data.ProfileEnd = (float)profile["end"].AsReal(); + data.ProfileHollow = (float)profile["hollow"].AsReal(); + data.ProfileCurve = (ProfileCurve)profile["curve"].AsInteger(); + data.ProfileHole = (HoleType)profile["hole"].AsInteger(); + + #endregion Path/Profile + + prim.PrimData = data; + + if (map["phantom"].AsBoolean()) + prim.Flags |= PrimFlags.Phantom; + + if (map["physical"].AsBoolean()) + prim.Flags |= PrimFlags.Physics; + + if (map["shadows"].AsBoolean()) + prim.Flags |= PrimFlags.CastShadows; + + prim.ParentID = (uint)map["parentid"].AsInteger(); + prim.Position = ((LLSDArray)map["position"]).AsVector3(); + prim.Rotation = ((LLSDArray)map["rotation"]).AsQuaternion(); + prim.Scale = ((LLSDArray)map["scale"]).AsVector3(); + prim.Flexible = FlexibleData.FromLLSD(map["flex"]); + prim.Light = LightData.FromLLSD(map["light"]); + prim.Sculpt = SculptData.FromLLSD(map["sculpt"]); + prim.Textures = TextureEntry.FromLLSD(map["textures"]); + if (!string.IsNullOrEmpty(map["name"].AsString())) + { + prim.Properties.Name = map["name"].AsString(); + } + + if (!string.IsNullOrEmpty(map["description"].AsString())) + { + prim.Properties.Description = map["description"].AsString(); + } + + return prim; + } + + public int SetExtraParamsFromBytes(byte[] data, int pos) + { + int i = pos; + int totalLength = 1; + + if (data.Length == 0 || pos >= data.Length) + return 0; + + byte extraParamCount = data[i++]; + + for (int k = 0; k < extraParamCount; k++) + { + ExtraParamType type = (ExtraParamType)Helpers.BytesToUInt16(data, i); + i += 2; + + uint paramLength = Helpers.BytesToUInt(data, i); + i += 4; + + if (type == ExtraParamType.Flexible) + Flexible = new FlexibleData(data, i); + else if (type == ExtraParamType.Light) + Light = new LightData(data, i); + else if (type == ExtraParamType.Sculpt) + Sculpt = new SculptData(data, i); + + i += (int)paramLength; + totalLength += (int)paramLength + 6; + } + + return totalLength; + } + + #endregion Public Methods + + #region Overrides + + public override bool Equals(object obj) + { + return (obj is Primitive) ? this == (Primitive)obj : false; + } + + public bool Equals(Primitive other) + { + return this == other; + } + + public override string ToString() + { + switch (PrimData.PCode) + { + case PCode.Prim: + return String.Format("{0} ({1})", PrimData.Type, ID); + default: + return String.Format("{0} ({1})", PrimData.PCode, ID); + } + } + + public override int GetHashCode() + { + return ID.GetHashCode(); + } + + #endregion Overrides + + #region Operators + + public static bool operator ==(Primitive lhs, Primitive rhs) + { + return (lhs.ID == rhs.ID); + } + + public static bool operator !=(Primitive lhs, Primitive rhs) + { + return !(lhs.ID == rhs.ID); + } + + #endregion Operators + + #region Parameter Packing Methods + + public static ushort PackBeginCut(float beginCut) + { + return (ushort)Math.Round(beginCut / CUT_QUANTA); + } + + public static ushort PackEndCut(float endCut) + { + return (ushort)(50000 - (ushort)Math.Round(endCut / CUT_QUANTA)); + } + + public static byte PackPathScale(float pathScale) + { + return (byte)(200 - (byte)Math.Round(pathScale / SCALE_QUANTA)); + } + + public static sbyte PackPathShear(float pathShear) + { + return (sbyte)Math.Round(pathShear / SHEAR_QUANTA); + } + + /// + /// Packs PathTwist, PathTwistBegin, PathRadiusOffset, and PathSkew + /// parameters in to signed eight bit values + /// + /// Floating point parameter to pack + /// Signed eight bit value containing the packed parameter + public static sbyte PackPathTwist(float pathTwist) + { + return (sbyte)Math.Round(pathTwist / SCALE_QUANTA); + } + + public static sbyte PackPathTaper(float pathTaper) + { + return (sbyte)Math.Round(pathTaper / TAPER_QUANTA); + } + + public static byte PackPathRevolutions(float pathRevolutions) + { + return (byte)Math.Round((pathRevolutions - 1f) / REV_QUANTA); + } + + public static ushort PackProfileHollow(float profileHollow) + { + return (ushort)Math.Round(profileHollow / HOLLOW_QUANTA); + } + + #endregion Parameter Packing Methods + + #region Parameter Unpacking Methods + + public static float UnpackBeginCut(ushort beginCut) + { + return (float)beginCut * CUT_QUANTA; + } + + public static float UnpackEndCut(ushort endCut) + { + return (float)(50000 - endCut) * CUT_QUANTA; + } + + public static float UnpackPathScale(byte pathScale) + { + return (float)(200 - pathScale) * SCALE_QUANTA; + } + + public static float UnpackPathShear(sbyte pathShear) + { + return (float)pathShear * SHEAR_QUANTA; + } + + /// + /// Unpacks PathTwist, PathTwistBegin, PathRadiusOffset, and PathSkew + /// parameters from signed eight bit integers to floating point values + /// + /// Signed eight bit value to unpack + /// Unpacked floating point value + public static float UnpackPathTwist(sbyte pathTwist) + { + return (float)pathTwist * SCALE_QUANTA; + } + + public static float UnpackPathTaper(sbyte pathTaper) + { + return (float)pathTaper * TAPER_QUANTA; + } + + public static float UnpackPathRevolutions(byte pathRevolutions) + { + return (float)pathRevolutions * REV_QUANTA + 1f; + } + + public static float UnpackProfileHollow(ushort profileHollow) + { + return (float)profileHollow * HOLLOW_QUANTA; + } + + #endregion Parameter Unpacking Methods + } +} diff --git a/OpenMetaverse/TextureEntry.cs b/OpenMetaverse/Primitives/TextureEntry.cs similarity index 89% rename from OpenMetaverse/TextureEntry.cs rename to OpenMetaverse/Primitives/TextureEntry.cs index 315393a7..ac97146a 100644 --- a/OpenMetaverse/TextureEntry.cs +++ b/OpenMetaverse/Primitives/TextureEntry.cs @@ -137,8 +137,38 @@ namespace OpenMetaverse #endregion Enumerations - public abstract partial class LLObject + public partial class Primitive { + #region Enums + + /// + /// Texture animation mode + /// + [Flags] + public enum TextureAnimMode : uint + { + /// Disable texture animation + ANIM_OFF = 0x00, + /// Enable texture animation + ANIM_ON = 0x01, + /// Loop when animating textures + LOOP = 0x02, + /// Animate in reverse direction + REVERSE = 0x04, + /// Animate forward then reverse + PING_PONG = 0x08, + /// Slide texture smoothly instead of frame-stepping + SMOOTH = 0x10, + /// Rotate texture instead of using frames + ROTATE = 0x20, + /// Scale texture instead of using frames + SCALE = 0x40, + } + + #endregion Enums + + #region Subclasses + /// /// A single textured face. Don't instantiate this class yourself, use the /// methods in TextureEntry @@ -449,7 +479,7 @@ namespace OpenMetaverse tex["mapping"] = LLSD.FromInteger((int)TexMapType); tex["glow"] = LLSD.FromReal(Glow); - if (TextureID != LLObject.TextureEntry.WHITE_TEXTURE) + if (TextureID != Primitive.TextureEntry.WHITE_TEXTURE) tex["imageid"] = LLSD.FromUUID(TextureID); else tex["imageid"] = LLSD.FromUUID(UUID.Zero); @@ -1108,5 +1138,89 @@ namespace OpenMetaverse #endregion Helpers } + + /// + /// Controls the texture animation of a particular prim + /// + public struct TextureAnimation + { + /// + public TextureAnimMode Flags; + /// + public uint Face; + /// + public uint SizeX; + /// + public uint SizeY; + /// + public float Start; + /// + public float Length; + /// + public float Rate; + + /// + /// + /// + /// + /// + public TextureAnimation(byte[] data, int pos) + { + if (data.Length >= 16) + { + Flags = (TextureAnimMode)((uint)data[pos++]); + Face = (uint)data[pos++]; + SizeX = (uint)data[pos++]; + SizeY = (uint)data[pos++]; + + Start = Helpers.BytesToFloat(data, pos); + Length = Helpers.BytesToFloat(data, pos + 4); + Rate = Helpers.BytesToFloat(data, pos + 8); + } + else + { + Flags = 0; + Face = 0; + SizeX = 0; + SizeY = 0; + + Start = 0.0f; + Length = 0.0f; + Rate = 0.0f; + } + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] data = new byte[16]; + int pos = 0; + + data[pos++] = (byte)Flags; + data[pos++] = (byte)Face; + data[pos++] = (byte)SizeX; + data[pos++] = (byte)SizeY; + + Helpers.FloatToBytes(Start).CopyTo(data, pos); + Helpers.FloatToBytes(Length).CopyTo(data, pos + 4); + Helpers.FloatToBytes(Rate).CopyTo(data, pos + 4); + + return data; + } + } + + #endregion Subclasses + + #region Public Members + + /// + public TextureEntry Textures; + /// + public TextureAnimation TextureAnim; + + #endregion Public Members } } diff --git a/OpenMetaverse/Prims.cs b/OpenMetaverse/Prims.cs index 4406240c..2cb1b55e 100644 --- a/OpenMetaverse/Prims.cs +++ b/OpenMetaverse/Prims.cs @@ -30,7 +30,7 @@ using OpenMetaverse.StructuredData; namespace OpenMetaverse { - public partial class Primitive : LLObject + public partial class Primitive : MetaverseObject { #region Enums @@ -533,34 +533,34 @@ namespace OpenMetaverse public override string ToString() { return String.Format("ID: {0}, GroupID: {1}, ParentID: {2}, LocalID: {3}, Flags: {4}, " + - "State: {5}, PCode: {6}, Material: {7}", ID, GroupID, ParentID, LocalID, Flags, Data.State, - Data.PCode, Data.Material); + "State: {5}, PCode: {6}, Material: {7}", ID, GroupID, ParentID, LocalID, Flags, PrimData.State, + PrimData.PCode, PrimData.Material); } public LLSD GetLLSD() { LLSDMap path = new LLSDMap(14); - path["begin"] = LLSD.FromReal(Data.PathBegin); - path["curve"] = LLSD.FromInteger((int)Data.PathCurve); - path["end"] = LLSD.FromReal(Data.PathEnd); - path["radius_offset"] = LLSD.FromReal(Data.PathRadiusOffset); - path["revolutions"] = LLSD.FromReal(Data.PathRevolutions); - path["scale_x"] = LLSD.FromReal(Data.PathScaleX); - path["scale_y"] = LLSD.FromReal(Data.PathScaleY); - path["shear_x"] = LLSD.FromReal(Data.PathShearX); - path["shear_y"] = LLSD.FromReal(Data.PathShearY); - path["skew"] = LLSD.FromReal(Data.PathSkew); - path["taper_x"] = LLSD.FromReal(Data.PathTaperX); - path["taper_y"] = LLSD.FromReal(Data.PathTaperY); - path["twist"] = LLSD.FromReal(Data.PathTwist); - path["twist_begin"] = LLSD.FromReal(Data.PathTwistBegin); + path["begin"] = LLSD.FromReal(PrimData.PathBegin); + path["curve"] = LLSD.FromInteger((int)PrimData.PathCurve); + path["end"] = LLSD.FromReal(PrimData.PathEnd); + path["radius_offset"] = LLSD.FromReal(PrimData.PathRadiusOffset); + path["revolutions"] = LLSD.FromReal(PrimData.PathRevolutions); + path["scale_x"] = LLSD.FromReal(PrimData.PathScaleX); + path["scale_y"] = LLSD.FromReal(PrimData.PathScaleY); + path["shear_x"] = LLSD.FromReal(PrimData.PathShearX); + path["shear_y"] = LLSD.FromReal(PrimData.PathShearY); + path["skew"] = LLSD.FromReal(PrimData.PathSkew); + path["taper_x"] = LLSD.FromReal(PrimData.PathTaperX); + path["taper_y"] = LLSD.FromReal(PrimData.PathTaperY); + path["twist"] = LLSD.FromReal(PrimData.PathTwist); + path["twist_begin"] = LLSD.FromReal(PrimData.PathTwistBegin); LLSDMap profile = new LLSDMap(4); - profile["begin"] = LLSD.FromReal(Data.ProfileBegin); - profile["curve"] = LLSD.FromInteger((int)Data.ProfileCurve); - profile["hole"] = LLSD.FromInteger((int)Data.ProfileHole); - profile["end"] = LLSD.FromReal(Data.ProfileEnd); - profile["hollow"] = LLSD.FromReal(Data.ProfileHollow); + profile["begin"] = LLSD.FromReal(PrimData.ProfileBegin); + profile["curve"] = LLSD.FromInteger((int)PrimData.ProfileCurve); + profile["hole"] = LLSD.FromInteger((int)PrimData.ProfileHole); + profile["end"] = LLSD.FromReal(PrimData.ProfileEnd); + profile["hollow"] = LLSD.FromReal(PrimData.ProfileHollow); LLSDMap volume = new LLSDMap(2); volume["path"] = path; @@ -574,7 +574,7 @@ namespace OpenMetaverse prim["position"] = LLSD.FromVector3(Position); prim["rotation"] = LLSD.FromQuaternion(Rotation); prim["scale"] = LLSD.FromVector3(Scale); - prim["material"] = LLSD.FromInteger((int)Data.Material); + prim["material"] = LLSD.FromInteger((int)PrimData.Material); prim["shadows"] = LLSD.FromBoolean(((Flags & ObjectFlags.CastShadows) != 0)); prim["textures"] = Textures.GetLLSD(); prim["volume"] = volume; @@ -591,7 +591,7 @@ namespace OpenMetaverse public static Primitive FromLLSD(LLSD llsd) { Primitive prim = new Primitive(); - LLObject.ObjectData data = new ObjectData(); + MetaverseObject.ObjectData data = new ObjectData(); LLSDMap map = (LLSDMap)llsd; LLSDMap volume = (LLSDMap)map["volume"]; @@ -623,7 +623,7 @@ namespace OpenMetaverse #endregion Path/Profile - prim.Data = data; + prim.PrimData = data; if (map["phantom"].AsBoolean()) prim.Flags |= ObjectFlags.Phantom; @@ -638,7 +638,7 @@ namespace OpenMetaverse prim.Position = ((LLSDArray)map["position"]).AsVector3(); prim.Rotation = ((LLSDArray)map["rotation"]).AsQuaternion(); prim.Scale = ((LLSDArray)map["scale"]).AsVector3(); - prim.Data.Material = (MaterialType)map["material"].AsInteger(); + prim.PrimData.Material = (MaterialType)map["material"].AsInteger(); prim.Flexible = FlexibleData.FromLLSD(map["flex"]); prim.Light = LightData.FromLLSD(map["light"]); prim.Sculpt = SculptData.FromLLSD(map["sculpt"]); diff --git a/OpenMetaverse/Rendering/Rendering.cs b/OpenMetaverse/Rendering/Rendering.cs index b5c8fbcd..0eb3f7c4 100644 --- a/OpenMetaverse/Rendering/Rendering.cs +++ b/OpenMetaverse/Rendering/Rendering.cs @@ -145,7 +145,7 @@ namespace OpenMetaverse.Rendering public List Indices; public List Edge; public FaceMask Mask; - public LLObject.TextureEntryFace TextureFace; + public Primitive.TextureEntryFace TextureFace; public object UserData; public override string ToString() @@ -189,7 +189,7 @@ namespace OpenMetaverse.Rendering } else { - return String.Format("{0} ({1})", Prim.LocalID, Prim.Data); + return String.Format("{0} ({1})", Prim.LocalID, Prim.PrimData); } } } diff --git a/OpenMetaverse/Types/Matrix4.cs b/OpenMetaverse/Types/Matrix4.cs index 375ae92a..d52fb5f9 100644 --- a/OpenMetaverse/Types/Matrix4.cs +++ b/OpenMetaverse/Types/Matrix4.cs @@ -1074,5 +1074,15 @@ namespace OpenMetaverse } #endregion Operators + + /// A 4x4 matrix containing all zeroes + public static readonly Matrix4 Zero = new Matrix4(); + + /// A 4x4 identity matrix + public static readonly Matrix4 Identity = new Matrix4( + 1f, 0f, 0f, 0f, + 0f, 1f, 0f, 0f, + 0f, 0f, 1f, 0f, + 0f, 0f, 0f, 1f); } } diff --git a/Programs/PrimWorkshop/frmBrowser.cs b/Programs/PrimWorkshop/frmBrowser.cs index 62bfa188..cc703d53 100644 --- a/Programs/PrimWorkshop/frmBrowser.cs +++ b/Programs/PrimWorkshop/frmBrowser.cs @@ -351,8 +351,8 @@ namespace PrimWorkshop { for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) { - LLObject.TextureEntryFace face = prim.Textures.FaceTextures[i]; - if (face != null && face.TextureID != UUID.Zero && face.TextureID != LLObject.TextureEntry.WHITE_TEXTURE) + Primitive.TextureEntryFace face = prim.Textures.FaceTextures[i]; + if (face != null && face.TextureID != UUID.Zero && face.TextureID != Primitive.TextureEntry.WHITE_TEXTURE) { if (!textureList.Contains(face.TextureID)) textureList.Add(face.TextureID); @@ -951,7 +951,7 @@ namespace PrimWorkshop data.Indices = face.Indices.ToArray(); // Texture transform for this face - LLObject.TextureEntryFace teFace = prim.Textures.GetFace((uint)j); + Primitive.TextureEntryFace teFace = prim.Textures.GetFace((uint)j); Render.Plugin.TransformTexCoords(face.Vertices, face.Center, teFace); // Texcoords for this face @@ -964,7 +964,7 @@ namespace PrimWorkshop // Texture for this face if (teFace.TextureID != UUID.Zero && - teFace.TextureID != LLObject.TextureEntry.WHITE_TEXTURE) + teFace.TextureID != Primitive.TextureEntry.WHITE_TEXTURE) { lock (Textures) { @@ -1322,7 +1322,7 @@ StartRender: } else { - if (face.TextureFace.TextureID == LLObject.TextureEntry.WHITE_TEXTURE || + if (face.TextureFace.TextureID == Primitive.TextureEntry.WHITE_TEXTURE || face.TextureFace.TextureID == UUID.Zero) { Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL); diff --git a/Programs/PrimWorkshop/frmPrimWorkshop.cs b/Programs/PrimWorkshop/frmPrimWorkshop.cs index 1d3fcd9e..a70d0bb9 100644 --- a/Programs/PrimWorkshop/frmPrimWorkshop.cs +++ b/Programs/PrimWorkshop/frmPrimWorkshop.cs @@ -306,7 +306,7 @@ namespace PrimWorkshop data.Indices = face.Indices.ToArray(); // Texture transform for this face - LLObject.TextureEntryFace teFace = prim.Textures.GetFace((uint)j); + Primitive.TextureEntryFace teFace = prim.Textures.GetFace((uint)j); Render.Plugin.TransformTexCoords(face.Vertices, face.Center, teFace); // Texcoords for this face diff --git a/Programs/PrimWorkshop/meshtoobj.cs b/Programs/PrimWorkshop/meshtoobj.cs index 70bef77c..665b073e 100644 --- a/Programs/PrimWorkshop/meshtoobj.cs +++ b/Programs/PrimWorkshop/meshtoobj.cs @@ -37,7 +37,7 @@ namespace PrimWorkshop if (face.Vertices.Count > 2) { string mtlName = String.Format("material{0}-{1}", i, face.ID); - LLObject.TextureEntryFace tex = face.TextureFace; + Primitive.TextureEntryFace tex = face.TextureFace; string texName = tex.TextureID.ToString() + ".tga"; // FIXME: Convert the source to TGA (if needed) and copy to the destination @@ -65,7 +65,7 @@ namespace PrimWorkshop mtl.AppendLine("Tr " + tex.RGBA.A); mtl.AppendLine("Ns " + shiny); mtl.AppendLine("illum 1"); - if (tex.TextureID != UUID.Zero && tex.TextureID != LLObject.TextureEntry.WHITE_TEXTURE) + if (tex.TextureID != UUID.Zero && tex.TextureID != Primitive.TextureEntry.WHITE_TEXTURE) mtl.AppendLine("map_Kd ./" + texName); mtl.AppendLine(); diff --git a/Programs/Simian/Agent.cs b/Programs/Simian/Agent.cs index 4815e627..00cf3fe8 100644 --- a/Programs/Simian/Agent.cs +++ b/Programs/Simian/Agent.cs @@ -26,7 +26,7 @@ namespace Simian public byte[] VisualParams = new byte[218]; // TODO: Replace byte with enum public byte State; - public LLObject.ObjectFlags Flags; + public PrimFlags Flags; public UUID InventoryRoot; public UUID InventoryLibRoot; diff --git a/Programs/Simian/Extensions/AvatarManager.cs b/Programs/Simian/Extensions/AvatarManager.cs index b052923e..382772c0 100644 --- a/Programs/Simian/Extensions/AvatarManager.cs +++ b/Programs/Simian/Extensions/AvatarManager.cs @@ -6,7 +6,7 @@ using OpenMetaverse.Packets; namespace Simian.Extensions { - class AvatarManager : ISimianExtension, IAvatarManager + class AvatarManager : ISimianExtension, IAvatarProvider { Simian Server; int currentWearablesSerialNum = -1; @@ -205,7 +205,7 @@ namespace Simian.Extensions Logger.DebugLog("Updating avatar appearance"); - agent.Avatar.Textures = new LLObject.TextureEntry(set.ObjectData.TextureEntry, 0, + agent.Avatar.Textures = new Primitive.TextureEntry(set.ObjectData.TextureEntry, 0, set.ObjectData.TextureEntry.Length); // Update agent visual params @@ -214,8 +214,9 @@ namespace Simian.Extensions //TODO: What is WearableData used for? - ObjectUpdatePacket update = Movement.BuildFullUpdate(agent, agent.Avatar, Server.RegionHandle, - agent.State, agent.Flags | LLObject.ObjectFlags.ObjectYouOwner); + ObjectUpdatePacket update = Movement.BuildFullUpdate(agent.Avatar, + NameValue.NameValuesToString(agent.Avatar.NameValues), Server.RegionHandle, + agent.State, agent.Flags | PrimFlags.ObjectYouOwner); agent.SendPacket(update); // Send out this appearance to all other connected avatars diff --git a/Programs/Simian/Extensions/Movement.cs b/Programs/Simian/Extensions/Movement.cs index 30c8e5bd..dd9cbc86 100644 --- a/Programs/Simian/Extensions/Movement.cs +++ b/Programs/Simian/Extensions/Movement.cs @@ -17,7 +17,7 @@ namespace Simian.Extensions const float SQRT_TWO = 1.41421356f; Simian server; - AvatarManager avatarManager; + AvatarManager Avatars; Timer updateTimer; long lastTick; @@ -123,22 +123,22 @@ namespace Simian.Extensions agent.Avatar.Acceleration = move * speed; if (movingHorizontally) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.FLY)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.FLY)) animsChanged = true; } else if (heldUp && !heldDown) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.HOVER_UP)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.HOVER_UP)) animsChanged = true; } else if (heldDown && !heldUp) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.HOVER_DOWN)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.HOVER_DOWN)) animsChanged = true; } else { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.HOVER)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.HOVER)) animsChanged = true; } } @@ -146,7 +146,7 @@ namespace Simian.Extensions { agent.Avatar.Acceleration /= 1 + (seconds / SQRT_TWO); - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.FALLDOWN)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.FALLDOWN)) animsChanged = true; } else //on the ground @@ -156,34 +156,34 @@ namespace Simian.Extensions { if (heldDown) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.CROUCHWALK)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.CROUCHWALK)) animsChanged = true; } else if (agent.Running) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.RUN)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.RUN)) animsChanged = true; } else { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.WALK)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.WALK)) animsChanged = true; } } else if (heldDown) { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.CROUCH)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.CROUCH)) animsChanged = true; } else { - if (server.AvatarManager.SetDefaultAnimation(agent, Animations.STAND)) + if (server.Avatars.SetDefaultAnimation(agent, Animations.STAND)) animsChanged = true; } } if (animsChanged) - server.AvatarManager.SendAnimations(agent); + server.Avatars.SendAnimations(agent); agent.Avatar.Velocity = agent.Avatar.Acceleration; agent.Avatar.Position += agent.Avatar.Velocity; @@ -207,9 +207,10 @@ namespace Simian.Extensions agent.Avatar.Rotation = update.AgentData.BodyRotation; agent.ControlFlags = (AgentManager.ControlFlags)update.AgentData.ControlFlags; agent.State = update.AgentData.State; - agent.Flags = (LLObject.ObjectFlags)update.AgentData.Flags; + agent.Flags = (PrimFlags)update.AgentData.Flags; - ObjectUpdatePacket fullUpdate = BuildFullUpdate(agent, agent.Avatar, server.RegionHandle, + ObjectUpdatePacket fullUpdate = BuildFullUpdate(agent.Avatar, + NameValue.NameValuesToString(agent.Avatar.NameValues), server.RegionHandle, agent.State, agent.Flags); lock (server.Agents) @@ -263,19 +264,20 @@ namespace Simian.Extensions heightWidth.HeightWidthBlock.Height, heightWidth.HeightWidthBlock.Width), Helpers.LogLevel.Info); } - public static ObjectUpdatePacket BuildFullUpdate(Agent agent, LLObject obj, ulong regionHandle, byte state, LLObject.ObjectFlags flags) + public static ObjectUpdatePacket BuildFullUpdate(Primitive obj, string nameValues, ulong regionHandle, + byte state, PrimFlags flags) { byte[] objectData = new byte[60]; int pos = 0; - agent.Avatar.Position.GetBytes().CopyTo(objectData, pos); + obj.Position.GetBytes().CopyTo(objectData, pos); pos += 12; - agent.Avatar.Velocity.GetBytes().CopyTo(objectData, pos); + obj.Velocity.GetBytes().CopyTo(objectData, pos); pos += 12; - agent.Avatar.Acceleration.GetBytes().CopyTo(objectData, pos); + obj.Acceleration.GetBytes().CopyTo(objectData, pos); pos += 12; - agent.Avatar.Rotation.GetBytes().CopyTo(objectData, pos); + obj.Rotation.GetBytes().CopyTo(objectData, pos); pos += 12; - agent.Avatar.AngularVelocity.GetBytes().CopyTo(objectData, pos); + obj.AngularVelocity.GetBytes().CopyTo(objectData, pos); ObjectUpdatePacket update = new ObjectUpdatePacket(); update.RegionData.RegionHandle = regionHandle; @@ -284,44 +286,44 @@ namespace Simian.Extensions update.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); update.ObjectData[0].ClickAction = (byte)0; update.ObjectData[0].CRC = 0; - update.ObjectData[0].ExtraParams = new byte[0]; - update.ObjectData[0].Flags = 0; + update.ObjectData[0].ExtraParams = new byte[0]; //FIXME: + update.ObjectData[0].Flags = (byte)flags; update.ObjectData[0].FullID = obj.ID; update.ObjectData[0].Gain = 0; update.ObjectData[0].ID = obj.LocalID; update.ObjectData[0].JointAxisOrAnchor = Vector3.Zero; update.ObjectData[0].JointPivot = Vector3.Zero; update.ObjectData[0].JointType = (byte)0; - update.ObjectData[0].Material = (byte)LLObject.MaterialType.Flesh; + update.ObjectData[0].Material = (byte)obj.PrimData.Material; update.ObjectData[0].MediaURL = new byte[0]; - update.ObjectData[0].NameValue = Utils.StringToBytes(NameValue.NameValuesToString(agent.Avatar.NameValues)); + update.ObjectData[0].NameValue = Utils.StringToBytes(nameValues); update.ObjectData[0].ObjectData = objectData; - update.ObjectData[0].OwnerID = UUID.Zero; - update.ObjectData[0].ParentID = 0; - update.ObjectData[0].PathBegin = 0; - update.ObjectData[0].PathCurve = (byte)16; - update.ObjectData[0].PathEnd = 0; - update.ObjectData[0].PathRadiusOffset = (sbyte)0; - update.ObjectData[0].PathRevolutions = (byte)0; - update.ObjectData[0].PathScaleX = (byte)100; - update.ObjectData[0].PathScaleY = (byte)100; - update.ObjectData[0].PathShearX = (byte)0; - update.ObjectData[0].PathShearY = (byte)0; - update.ObjectData[0].PathSkew = (sbyte)0; - update.ObjectData[0].PathTaperX = (sbyte)0; - update.ObjectData[0].PathTaperY = (sbyte)0; - update.ObjectData[0].PathTwist = (sbyte)0; - update.ObjectData[0].PathTwistBegin = (sbyte)0; - update.ObjectData[0].PCode = (byte)PCode.Avatar; - update.ObjectData[0].ProfileBegin = 0; - update.ObjectData[0].ProfileCurve = (byte)1; - update.ObjectData[0].ProfileEnd = 0; - update.ObjectData[0].ProfileHollow = 0; + update.ObjectData[0].OwnerID = obj.Properties.OwnerID; + update.ObjectData[0].ParentID = obj.ParentID; + update.ObjectData[0].PathBegin = Primitive.PackBeginCut(obj.PrimData.PathBegin); + update.ObjectData[0].PathCurve = (byte)obj.PrimData.PathCurve; + update.ObjectData[0].PathEnd = Primitive.PackEndCut(obj.PrimData.PathEnd); + update.ObjectData[0].PathRadiusOffset = Primitive.PackPathTwist(obj.PrimData.PathRadiusOffset); + update.ObjectData[0].PathRevolutions = Primitive.PackPathRevolutions(obj.PrimData.PathRevolutions); + update.ObjectData[0].PathScaleX = Primitive.PackPathScale(obj.PrimData.PathScaleX); + update.ObjectData[0].PathScaleY = Primitive.PackPathScale(obj.PrimData.PathScaleY); + update.ObjectData[0].PathShearX = (byte)Primitive.PackPathShear(obj.PrimData.PathShearX); + update.ObjectData[0].PathShearY = (byte)Primitive.PackPathShear(obj.PrimData.PathShearY); + update.ObjectData[0].PathSkew = Primitive.PackPathTwist(obj.PrimData.PathSkew); + update.ObjectData[0].PathTaperX = Primitive.PackPathTaper(obj.PrimData.PathTaperX); + update.ObjectData[0].PathTaperY = Primitive.PackPathTaper(obj.PrimData.PathTaperY); + update.ObjectData[0].PathTwist = Primitive.PackPathTwist(obj.PrimData.PathTwist); + update.ObjectData[0].PathTwistBegin = Primitive.PackPathTwist(obj.PrimData.PathTwistBegin); + update.ObjectData[0].PCode = (byte)obj.PrimData.PCode; + update.ObjectData[0].ProfileBegin = Primitive.PackBeginCut(obj.PrimData.ProfileBegin); + update.ObjectData[0].ProfileCurve = (byte)obj.PrimData.ProfileCurve; + update.ObjectData[0].ProfileEnd = Primitive.PackEndCut(obj.PrimData.ProfileEnd); + update.ObjectData[0].ProfileHollow = Primitive.PackProfileHollow(obj.PrimData.ProfileHollow); update.ObjectData[0].PSBlock = new byte[0]; update.ObjectData[0].TextColor = Vector3.Zero.GetBytes(); update.ObjectData[0].TextureAnim = new byte[0]; update.ObjectData[0].TextureEntry = obj.Textures.ToBytes(); - update.ObjectData[0].Radius = 0f; + update.ObjectData[0].Radius = 0f; // Sound update.ObjectData[0].Scale = obj.Scale; update.ObjectData[0].Sound = UUID.Zero; update.ObjectData[0].State = state; diff --git a/Programs/Simian/Extensions/RenderingPluginMesher.cs b/Programs/Simian/Extensions/RenderingPluginMesher.cs new file mode 100644 index 00000000..126d3182 --- /dev/null +++ b/Programs/Simian/Extensions/RenderingPluginMesher.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.Rendering; + +namespace Simian.Extensions +{ + public class RenderingPluginMesher : ISimianExtension, IMeshingProvider + { + Simian Server; + IRendering Renderer; + + public RenderingPluginMesher(Simian server) + { + Server = server; + } + + public void Start() + { + // Search for a the best available OpenMetaverse.Rendering plugin + List renderers = RenderingLoader.ListRenderers(AppDomain.CurrentDomain.BaseDirectory); + + string renderer = renderers.Find( + delegate(string current) { return current.Contains("OpenMetaverse.Rendering.GPL.dll"); }); + + if (String.IsNullOrEmpty(renderer)) + { + if (renderers.Count > 0) + { + renderer = renderers[0]; + } + else + { + Logger.Log("No suitable OpenMetaverse.Rendering plugins found", Helpers.LogLevel.Error); + return; + } + } + + Renderer = RenderingLoader.LoadRenderer(renderer); + } + + public void Stop() + { + } + + public SimpleMesh GenerateSimpleMesh(Primitive prim, DetailLevel lod) + { + return Renderer.GenerateSimpleMesh(prim, lod); + } + } +} diff --git a/Programs/Simian/Extensions/SceneManager.cs b/Programs/Simian/Extensions/SceneManager.cs index ac2c88b5..28ee8c5d 100644 --- a/Programs/Simian/Extensions/SceneManager.cs +++ b/Programs/Simian/Extensions/SceneManager.cs @@ -42,9 +42,11 @@ namespace Simian.Extensions avatar.Position = new Vector3(128f, 128f, 25f); avatar.Rotation = Quaternion.Identity; avatar.Scale = new Vector3(0.45f, 0.6f, 1.9f); + avatar.PrimData.Material = Material.Flesh; + avatar.PrimData.PCode = PCode.Avatar; // Create a default outfit for the avatar - LLObject.TextureEntry te = new LLObject.TextureEntry(new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97")); + Primitive.TextureEntry te = new Primitive.TextureEntry(new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97")); avatar.Textures = te; // Set the avatar name @@ -77,7 +79,8 @@ namespace Simian.Extensions foreach (Agent otherAgent in server.Agents.Values) { // Send ObjectUpdate packets for this avatar - ObjectUpdatePacket update = Movement.BuildFullUpdate(otherAgent, otherAgent.Avatar, + ObjectUpdatePacket update = Movement.BuildFullUpdate(otherAgent.Avatar, + NameValue.NameValuesToString(otherAgent.Avatar.NameValues), server.RegionHandle, otherAgent.State, otherAgent.Flags); agent.SendPacket(update); diff --git a/Programs/Simian/Interfaces/IAvatarManager.cs b/Programs/Simian/Interfaces/IAvatarProvider.cs similarity index 84% rename from Programs/Simian/Interfaces/IAvatarManager.cs rename to Programs/Simian/Interfaces/IAvatarProvider.cs index 4dbdfaab..ab1922bc 100644 --- a/Programs/Simian/Interfaces/IAvatarManager.cs +++ b/Programs/Simian/Interfaces/IAvatarProvider.cs @@ -3,7 +3,7 @@ using OpenMetaverse; namespace Simian { - public interface IAvatarManager + public interface IAvatarProvider { bool SetDefaultAnimation(Agent agent, UUID animID); bool AddAnimation(Agent agent, UUID animID); diff --git a/Programs/Simian/Interfaces/IMeshingProvider.cs b/Programs/Simian/Interfaces/IMeshingProvider.cs new file mode 100644 index 00000000..5c1b0526 --- /dev/null +++ b/Programs/Simian/Interfaces/IMeshingProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.Rendering; + +namespace Simian +{ + public interface IMeshingProvider + { + SimpleMesh GenerateSimpleMesh(Primitive prim, DetailLevel lod); + } +} diff --git a/Programs/Simian/Simian.cs b/Programs/Simian/Simian.cs index 2d3232aa..b3548f10 100644 --- a/Programs/Simian/Simian.cs +++ b/Programs/Simian/Simian.cs @@ -17,13 +17,13 @@ namespace Simian public HttpServer HttpServer; public UDPServer UDPServer; - public Dictionary SceneObjects = new Dictionary(); public ulong RegionHandle; public float[] Heightmap = new float[65536]; public Dictionary AssetStore = new Dictionary(); // Interfaces - public IAvatarManager AvatarManager; + public IAvatarProvider Avatars; + public IMeshingProvider Mesher; /// All of the agents currently connected to this UDP server public Dictionary Agents = new Dictionary(); @@ -98,18 +98,26 @@ namespace Simian void TryAssignToInterface(ISimianExtension extension) { - if (extension is IAvatarManager) + if (extension is IAvatarProvider) { - IAvatarManager manager = (IAvatarManager)extension; - AvatarManager = manager; + Avatars = (IAvatarProvider)extension; + } + else if (extension is IMeshingProvider) + { + Mesher = (IMeshingProvider)extension; } } bool CheckInterfaces() { - if (AvatarManager == null) + if (Avatars == null) { - Logger.Log("No AvatarManager interface loaded", Helpers.LogLevel.Error); + Logger.Log("No IAvatarProvider interface loaded", Helpers.LogLevel.Error); + return false; + } + if (Mesher == null) + { + Logger.Log("No IMeshingProvider interface loaded", Helpers.LogLevel.Error); return false; } @@ -291,9 +299,9 @@ namespace Simian agent.CircuitCode = CreateAgentCircuit(agent); agent.InventoryRoot = UUID.Random(); agent.InventoryLibRoot = UUID.Random(); - agent.Flags = LLObject.ObjectFlags.Physics | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectCopy | - LLObject.ObjectFlags.ObjectAnyOwner | LLObject.ObjectFlags.ObjectMove | LLObject.ObjectFlags.InventoryEmpty | - LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectYouOwner; + agent.Flags = PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | + PrimFlags.ObjectAnyOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | + PrimFlags.ObjectTransfer | PrimFlags.ObjectOwnerModify | PrimFlags.ObjectYouOwner; // Setup the agent inventory InventoryFolder rootFolder = new InventoryFolder(); diff --git a/Programs/Simian/SimulationObject.cs b/Programs/Simian/SimulationObject.cs new file mode 100644 index 00000000..ba9ee354 --- /dev/null +++ b/Programs/Simian/SimulationObject.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.Rendering; + +namespace Simian +{ + public class SimulationObject + { + public Primitive Params; + + protected Simian Server; + protected SimpleMesh[] Meshes = new SimpleMesh[4]; + protected SimpleMesh[] WorldTransformedMeshes = new SimpleMesh[4]; + protected Matrix4 WorldTransformation = Matrix4.Identity; + protected bool WorldTransformationSet = false; + + public SimulationObject(Primitive prim, Simian server) + { + Params = prim; + Server = server; + } + + public SimpleMesh GetMesh(DetailLevel lod) + { + int i = (int)lod; + + if (Meshes[i] != null) + { + return Meshes[i]; + } + else + { + if (Params is Primitive) + { + Primitive prim = (Primitive)Params; + SimpleMesh mesh = Server.Mesher.GenerateSimpleMesh(prim, lod); + Meshes[i] = mesh; + return mesh; + } + else + { + throw new NotImplementedException("Avatar mesh generation is currently not supported"); + } + } + } + + public SimpleMesh GetWorldMesh(DetailLevel lod, SimulationObject parent) + { + int i = (int)lod; + + if (WorldTransformedMeshes[i] != null) + { + return WorldTransformedMeshes[i]; + } + else + { + // Get the untransformed mesh + SimpleMesh mesh = GetMesh(lod); + + // Copy to our new mesh + SimpleMesh transformedMesh = new SimpleMesh(); + transformedMesh.Indices = new List(mesh.Indices); + transformedMesh.Path.Open = mesh.Path.Open; + transformedMesh.Path.Points = new List(mesh.Path.Points); + transformedMesh.Prim = mesh.Prim; + transformedMesh.Profile.Concave = mesh.Profile.Concave; + transformedMesh.Profile.Faces = new List(mesh.Profile.Faces); + transformedMesh.Profile.MaxX = mesh.Profile.MaxX; + transformedMesh.Profile.MinX = mesh.Profile.MinX; + transformedMesh.Profile.Open = mesh.Profile.Open; + transformedMesh.Profile.Positions = new List(mesh.Profile.Positions); + transformedMesh.Profile.TotalOutsidePoints = mesh.Profile.TotalOutsidePoints; + transformedMesh.Vertices = new List(mesh.Vertices); + + // Construct a matrix to transform to world space + Matrix4 transform = Matrix4.Identity; + + if (parent != null) + { + // Apply parent rotation and translation first + transform *= Matrix4.CreateFromQuaternion(parent.Params.Rotation); + transform *= Matrix4.CreateTranslation(parent.Params.Position); + } + + transform *= Matrix4.CreateScale(this.Params.Scale); + transform *= Matrix4.CreateFromQuaternion(this.Params.Rotation); + transform *= Matrix4.CreateTranslation(this.Params.Position); + + // Transform the mesh + for (int j = 0; j < transformedMesh.Vertices.Count; j++) + { + Vertex vertex = transformedMesh.Vertices[j]; + vertex.Position *= transform; + transformedMesh.Vertices[j] = vertex; + } + + WorldTransformedMeshes[i] = transformedMesh; + return transformedMesh; + } + } + } +} diff --git a/Programs/examples/Heightmap/Heightmap.cs b/Programs/examples/Heightmap/Heightmap.cs index 1ae8f1e5..3ccfb5c1 100644 --- a/Programs/examples/Heightmap/Heightmap.cs +++ b/Programs/examples/Heightmap/Heightmap.cs @@ -15,8 +15,6 @@ namespace Heightmap if (args.Length != 3) { Console.WriteLine("Usage: [FirstName] [LastName] [password]"); - Console.WriteLine("Press any key to continue..."); - Console.ReadKey(); return; } diff --git a/Programs/examples/TestClient/Commands/Appearance/AppearanceCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AppearanceCommand.cs index 4cab0b01..995858c3 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AppearanceCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AppearanceCommand.cs @@ -23,7 +23,7 @@ namespace OpenMetaverse.TestClient // Register a handler for the appearance event AutoResetEvent appearanceEvent = new AutoResetEvent(false); AppearanceManager.AppearanceUpdatedCallback callback = - delegate(LLObject.TextureEntry te) { appearanceEvent.Set(); }; + delegate(Primitive.TextureEntry te) { appearanceEvent.Set(); }; Client.Appearance.OnAppearanceUpdated += callback; // Start the appearance setting process (with baking enabled or disabled) diff --git a/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs index 73e8d55a..38085ee0 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AttachmentsCommand.cs @@ -23,7 +23,7 @@ namespace OpenMetaverse.TestClient for (int i = 0; i < attachments.Count; i++) { Primitive prim = attachments[i]; - AttachmentPoint point = Helpers.StateToAttachmentPoint(prim.Data.State); + AttachmentPoint point = Helpers.StateToAttachmentPoint(prim.PrimData.State); // TODO: Fetch properties for the objects with missing property sets so we can show names Logger.Log(String.Format("[Attachment @ {0}] LocalID: {1} UUID: {2} Offset: {3}", diff --git a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs index a4148b57..1fa9c6d2 100644 --- a/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Appearance/AvatarInfoCommand.cs @@ -36,7 +36,7 @@ namespace OpenMetaverse.TestClient.Commands.Appearance { if (foundAv.Textures.FaceTextures[i] != null) { - LLObject.TextureEntryFace face = foundAv.Textures.FaceTextures[i]; + Primitive.TextureEntryFace face = foundAv.Textures.FaceTextures[i]; AppearanceManager.TextureIndex type = (AppearanceManager.TextureIndex)i; output.AppendFormat("{0}: {1}", type, face.TextureID); diff --git a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs index 595f725e..7d7ae2ae 100644 --- a/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs @@ -53,7 +53,7 @@ namespace OpenMetaverse.TestClient for (int j = 0; j < targetAv.Textures.FaceTextures.Length; j++) { - LLObject.TextureEntryFace face = targetAv.Textures.FaceTextures[j]; + Primitive.TextureEntryFace face = targetAv.Textures.FaceTextures[j]; if (face != null) { diff --git a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs index 756914a1..64c9012b 100644 --- a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs @@ -129,7 +129,7 @@ namespace OpenMetaverse.TestClient int taskItems = 0; foreach (Primitive prim in Objects.Values) { - if ((prim.Flags & LLObject.ObjectFlags.InventoryEmpty) == 0) + if ((prim.Flags & PrimFlags.InventoryEmpty) == 0) { List items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000 * 30); @@ -153,7 +153,7 @@ namespace OpenMetaverse.TestClient return "Set permissions to " + Perms.ToString() + " on " + localIDs.Count + " objects and " + taskItems + " inventory items"; } - void Objects_OnObjectProperties(Simulator simulator, LLObject.ObjectProperties properties) + void Objects_OnObjectProperties(Simulator simulator, Primitive.ObjectProperties properties) { if (PermsSent) { diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index f3585b81..5b47000f 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -11,7 +11,7 @@ namespace OpenMetaverse.TestClient { List Textures = new List(); AutoResetEvent GotPermissionsEvent = new AutoResetEvent(false); - LLObject.ObjectPropertiesFamily Properties; + Primitive.ObjectProperties Properties; bool GotPermissions = false; UUID SelectedObject = UUID.Zero; @@ -115,7 +115,7 @@ namespace OpenMetaverse.TestClient { Primitive prim = prims[i]; - if (prim.Textures.DefaultTexture.TextureID != LLObject.TextureEntry.WHITE_TEXTURE && + if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) { Textures.Add(prim.Textures.DefaultTexture.TextureID); @@ -124,7 +124,7 @@ namespace OpenMetaverse.TestClient for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) { if (prim.Textures.FaceTextures[j] != null && - prim.Textures.FaceTextures[j].TextureID != LLObject.TextureEntry.WHITE_TEXTURE && + prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && !Textures.Contains(prim.Textures.FaceTextures[j].TextureID)) { Textures.Add(prim.Textures.FaceTextures[j].TextureID); @@ -216,14 +216,15 @@ namespace OpenMetaverse.TestClient } } - void Objects_OnObjectPropertiesFamily(Simulator simulator, LLObject.ObjectPropertiesFamily properties) + void Objects_OnObjectPropertiesFamily(Simulator simulator, Primitive.ObjectProperties properties, + ObjectPropertiesRequestType type) { - Properties = properties; + Properties.SetFamilyProperties(properties); GotPermissions = true; GotPermissionsEvent.Set(); } - void Objects_OnObjectProperties(Simulator simulator, LLObject.ObjectProperties properties) + void Objects_OnObjectProperties(Simulator simulator, Primitive.ObjectProperties properties) { lock (PrimsWaiting) { diff --git a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs index 4ea85b78..b2d5b0f4 100644 --- a/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/FindObjectsCommand.cs @@ -78,7 +78,7 @@ namespace OpenMetaverse.TestClient return AllPropertiesReceived.WaitOne(2000 + msPerRequest * objects.Count, false); } - void Objects_OnObjectProperties(Simulator simulator, LLObject.ObjectProperties properties) + void Objects_OnObjectProperties(Simulator simulator, Primitive.ObjectProperties properties) { lock (PrimsWaiting) { Primitive prim; diff --git a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs index c0a8d549..8c0e151e 100644 --- a/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ImportCommand.cs @@ -107,7 +107,7 @@ namespace OpenMetaverse.TestClient Quaternion rootRotation = linkset.RootPrim.Rotation; linkset.RootPrim.Rotation = Quaternion.Identity; - Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim.Data, GroupID, + Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim.PrimData, GroupID, linkset.RootPrim.Position, linkset.RootPrim.Scale, linkset.RootPrim.Rotation); if (!primDone.WaitOne(10000, false)) @@ -123,7 +123,7 @@ namespace OpenMetaverse.TestClient currentPrim = prim; currentPosition = prim.Position + linkset.RootPrim.Position; - Client.Objects.AddPrim(Client.Network.CurrentSim, prim.Data, GroupID, currentPosition, + Client.Objects.AddPrim(Client.Network.CurrentSim, prim.PrimData, GroupID, currentPosition, prim.Scale, prim.Rotation); if (!primDone.WaitOne(10000, false)) @@ -184,7 +184,7 @@ namespace OpenMetaverse.TestClient void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) { - if ((prim.Flags & LLObject.ObjectFlags.CreateSelected) == 0) + if ((prim.Flags & PrimFlags.CreateSelected) == 0) return; // We received an update for an object we didn't create switch (state) diff --git a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs index c612e8ed..5d66861e 100644 --- a/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/PrimRegexCommand.cs @@ -39,18 +39,18 @@ namespace OpenMetaverse.TestClient { if (prim.Text != null && regexPrimName.IsMatch(prim.Text.ToLower())) { - Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.PropertiesFamily.Name, - prim.ID, prim.Flags.ToString(), prim.Text, prim.PropertiesFamily.Description), Helpers.LogLevel.Info, Client); + Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.Properties.Name, + prim.ID, prim.Flags.ToString(), prim.Text, prim.Properties.Description), Helpers.LogLevel.Info, Client); } - else if (prim.PropertiesFamily.Name != null && regexPrimName.IsMatch(prim.PropertiesFamily.Name.ToLower())) + else if (prim.Properties.Name != null && regexPrimName.IsMatch(prim.Properties.Name.ToLower())) { - Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.PropertiesFamily.Name, - prim.ID, prim.Flags.ToString(), prim.Text, prim.PropertiesFamily.Description), Helpers.LogLevel.Info, Client); + Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.Properties.Name, + prim.ID, prim.Flags.ToString(), prim.Text, prim.Properties.Description), Helpers.LogLevel.Info, Client); } - else if (prim.PropertiesFamily.Description != null && regexPrimName.IsMatch(prim.PropertiesFamily.Description.ToLower())) + else if (prim.Properties.Description != null && regexPrimName.IsMatch(prim.Properties.Description.ToLower())) { - Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.PropertiesFamily.Name, - prim.ID, prim.Flags.ToString(), prim.Text, prim.PropertiesFamily.Description), Helpers.LogLevel.Info, Client); + Logger.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\nDESC='{4}", prim.Properties.Name, + prim.ID, prim.Flags.ToString(), prim.Text, prim.Properties.Description), Helpers.LogLevel.Info, Client); } } ); diff --git a/Programs/examples/TestClient/Commands/WhoCommand.cs b/Programs/examples/TestClient/Commands/WhoCommand.cs index 268d87f7..a4ea2a34 100644 --- a/Programs/examples/TestClient/Commands/WhoCommand.cs +++ b/Programs/examples/TestClient/Commands/WhoCommand.cs @@ -27,9 +27,8 @@ namespace OpenMetaverse.TestClient delegate(Avatar av) { result.AppendLine(); - result.AppendFormat("{0} (Group: {1}, Location: {2}/{3}, UUID: {4})", av.Name, - av.GroupName, (av.CurrentSim != null ? av.CurrentSim.Name : String.Empty), - av.Position, av.ID.ToString()); + result.AppendFormat("{0} (Group: {1}, Location: {2}, UUID: {3})", + av.Name, av.GroupName, av.Position, av.ID.ToString()); } ); } diff --git a/Programs/importprimscript/importprimscript.cs b/Programs/importprimscript/importprimscript.cs index 94840d60..c3c5ffb0 100644 --- a/Programs/importprimscript/importprimscript.cs +++ b/Programs/importprimscript/importprimscript.cs @@ -154,12 +154,12 @@ namespace importprimscript // Create basic spherical volume parameters. It will be set to // a scultpy in the callback for new objects being created - LLObject.ObjectData volume = new LLObject.ObjectData(); + Primitive.ConstructionData volume = new Primitive.ConstructionData(); volume.PCode = PCode.Prim; - volume.Material = LLObject.MaterialType.Wood; + volume.Material = Material.Wood; volume.PathScaleY = 0.5f; - volume.PathCurve = LLObject.PathCurve.Circle; - volume.ProfileCurve = LLObject.ProfileCurve.Circle; + volume.PathCurve = PathCurve.Circle; + volume.ProfileCurve = ProfileCurve.Circle; // Rez this prim CurrentSculpt = sculpties[i]; @@ -246,7 +246,7 @@ namespace importprimscript static void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) { - if (CurrentSculpt != null && (prim.Flags & LLObject.ObjectFlags.CreateSelected) != 0 && + if (CurrentSculpt != null && (prim.Flags & PrimFlags.CreateSelected) != 0 && !RezzedPrims.Contains(prim.LocalID)) { lock (RezzedPrims) RezzedPrims.Add(prim.LocalID); @@ -261,13 +261,13 @@ namespace importprimscript RootPosition + CurrentSculpt.Offset); // Set the texture - LLObject.TextureEntry textures = new LLObject.TextureEntry(CurrentSculpt.TextureID); + Primitive.TextureEntry textures = new Primitive.TextureEntry(CurrentSculpt.TextureID); Client.Objects.SetTextures(Client.Network.CurrentSim, prim.LocalID, textures); // Turn it in to a sculpted prim Primitive.SculptData sculpt = new Primitive.SculptData(); sculpt.SculptTexture = CurrentSculpt.SculptID; - sculpt.Type = Primitive.SculptType.Sphere; + sculpt.Type = SculptType.Sphere; Client.Objects.SetSculpt(Client.Network.CurrentSim, prim.LocalID, sculpt); // Set the prim name