public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive obj, ulong regionHandle, byte state, PrimFlags flags) { byte[] objectData = BuildObjectData(obj.Position, obj.Rotation, obj.Velocity, obj.Acceleration, obj.AngularVelocity); ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); update.ClickAction = (byte)obj.ClickAction; update.CRC = 0; update.ExtraParams = new byte[0]; //FIXME: Need a serializer for ExtraParams update.Flags = (byte)flags; update.FullID = obj.ID; update.Gain = obj.SoundGain; update.ID = obj.LocalID; update.JointAxisOrAnchor = obj.JointAxisOrAnchor; update.JointPivot = obj.JointPivot; update.JointType = (byte)obj.Joint; update.Material = (byte)obj.PrimData.Material; update.MediaURL = Utils.StringToBytes(obj.MediaURL); update.NameValue = Utils.StringToBytes(NameValue.NameValuesToString(obj.NameValues)); update.ObjectData = objectData; update.OwnerID = obj.Properties.OwnerID; update.ParentID = obj.ParentID; update.PathBegin = Primitive.PackBeginCut(obj.PrimData.PathBegin); update.PathCurve = (byte)obj.PrimData.PathCurve; update.PathEnd = Primitive.PackEndCut(obj.PrimData.PathEnd); update.PathRadiusOffset = Primitive.PackPathTwist(obj.PrimData.PathRadiusOffset); update.PathRevolutions = Primitive.PackPathRevolutions(obj.PrimData.PathRevolutions); update.PathScaleX = Primitive.PackPathScale(obj.PrimData.PathScaleX); update.PathScaleY = Primitive.PackPathScale(obj.PrimData.PathScaleY); update.PathShearX = (byte)Primitive.PackPathShear(obj.PrimData.PathShearX); update.PathShearY = (byte)Primitive.PackPathShear(obj.PrimData.PathShearY); update.PathSkew = Primitive.PackPathTwist(obj.PrimData.PathSkew); update.PathTaperX = Primitive.PackPathTaper(obj.PrimData.PathTaperX); update.PathTaperY = Primitive.PackPathTaper(obj.PrimData.PathTaperY); update.PathTwist = Primitive.PackPathTwist(obj.PrimData.PathTwist); update.PathTwistBegin = Primitive.PackPathTwist(obj.PrimData.PathTwistBegin); update.PCode = (byte)obj.PrimData.PCode; update.ProfileBegin = Primitive.PackBeginCut(obj.PrimData.ProfileBegin); update.ProfileCurve = (byte)obj.PrimData.ProfileCurve; update.ProfileEnd = Primitive.PackEndCut(obj.PrimData.ProfileEnd); update.ProfileHollow = Primitive.PackProfileHollow(obj.PrimData.ProfileHollow); update.PSBlock = new byte[0]; // FIXME: update.TextColor = obj.TextColor.GetBytes(true); update.TextureAnim = obj.TextureAnim.GetBytes(); update.TextureEntry = obj.Textures == null ? new byte[0] : obj.Textures.ToBytes(); update.Radius = obj.SoundRadius; update.Scale = obj.Scale; update.Sound = obj.Sound; update.State = state; update.Text = Utils.StringToBytes(obj.Text); update.UpdateFlags = (uint)flags; update.Data = new byte[0]; // FIXME: return(update); }
public OSDMap GetOSD() { Primitive.ConstructionData primData = Prim.PrimData; Primitive.ObjectProperties properties = Prim.Properties; OSDMap pathMap = new OSDMap(); pathMap["begin"] = OSD.FromReal(primData.PathBegin); pathMap["curve"] = OSD.FromInteger((int)primData.PathCurve); pathMap["end"] = OSD.FromReal(primData.PathEnd); pathMap["radius_offset"] = OSD.FromReal(primData.PathRadiusOffset); pathMap["revolutions"] = OSD.FromReal(primData.PathRevolutions); pathMap["scale_x"] = OSD.FromReal(primData.PathScaleX); pathMap["scale_y"] = OSD.FromReal(primData.PathScaleY); pathMap["shear_x"] = OSD.FromReal(primData.PathShearX); pathMap["shear_y"] = OSD.FromReal(primData.PathShearY); pathMap["skew"] = OSD.FromReal(primData.PathSkew); pathMap["taper_x"] = OSD.FromReal(primData.PathTaperX); pathMap["taper_y"] = OSD.FromReal(primData.PathTaperY); pathMap["twist"] = OSD.FromReal(primData.PathTwist); pathMap["twist_begin"] = OSD.FromReal(primData.PathTwistBegin); OSDMap profileMap = new OSDMap(); profileMap["begin"] = OSD.FromReal(primData.ProfileBegin); profileMap["curve"] = OSD.FromInteger((int)primData.ProfileCurve); profileMap["hole"] = OSD.FromInteger((int)primData.ProfileHole); profileMap["end"] = OSD.FromReal(primData.ProfileEnd); profileMap["hollow"] = OSD.FromReal(primData.ProfileHollow); OSDMap propertiesMap = new OSDMap(); if (properties != null) { propertiesMap["aggregate_perms"] = OSD.FromInteger(properties.AggregatePerms); propertiesMap["aggregate_perms_textures"] = OSD.FromInteger(properties.AggregatePermTextures); propertiesMap["aggregate_perms_textures_owner"] = OSD.FromInteger(properties.AggregatePermTexturesOwner); propertiesMap["category"] = OSD.FromInteger((int)properties.Category); propertiesMap["creation_date"] = OSD.FromDate(properties.CreationDate); propertiesMap["creator_id"] = OSD.FromUUID(properties.CreatorID); propertiesMap["description"] = OSD.FromString(properties.Description); propertiesMap["folder_id"] = OSD.FromUUID(properties.FolderID); propertiesMap["from_task_id"] = OSD.FromUUID(properties.FromTaskID); // properties.GroupID is redundant propertiesMap["inventory_serial"] = OSD.FromInteger(properties.InventorySerial); propertiesMap["item_id"] = OSD.FromUUID(properties.ItemID); propertiesMap["last_owner_id"] = OSD.FromUUID(properties.LastOwnerID); propertiesMap["name"] = OSD.FromString(properties.Name); // properties.ObjectID is redundant // properties.OwnerID is redundant propertiesMap["ownership_cost"] = OSD.FromInteger(properties.OwnershipCost); propertiesMap["permissions"] = properties.Permissions.GetOSD(); propertiesMap["sale_price"] = OSD.FromInteger(properties.SalePrice); propertiesMap["sale_type"] = OSD.FromInteger((int)properties.SaleType); propertiesMap["sit_name"] = OSD.FromString(properties.SitName); propertiesMap["touch_name"] = OSD.FromString(properties.TouchName); } OSDMap primMap = new OSDMap(); primMap["path"] = pathMap; primMap["profile"] = profileMap; primMap["properties"] = propertiesMap; primMap["acceleration"] = OSD.FromVector3(Prim.Acceleration); primMap["ang_velocity"] = OSD.FromVector3(Prim.AngularVelocity); primMap["click_action"] = OSD.FromInteger((int)Prim.ClickAction); primMap["flags"] = OSD.FromInteger((uint)Prim.Flags); primMap["group_id"] = OSD.FromUUID(Prim.GroupID); primMap["id"] = OSD.FromUUID(Prim.ID); primMap["local_id"] = OSD.FromInteger(Prim.LocalID); primMap["media_url"] = OSD.FromString(Prim.MediaURL); primMap["owner_id"] = OSD.FromUUID(Prim.OwnerID); primMap["parent_id"] = OSD.FromInteger(Prim.ParentID); primMap["particles"] = Prim.ParticleSys.GetOSD(); primMap["position"] = OSD.FromVector3(Prim.Position); primMap["rotation"] = OSD.FromQuaternion(Prim.Rotation); primMap["scale"] = OSD.FromVector3(Prim.Scale); primMap["scratch_pad"] = OSD.FromBinary(Prim.ScratchPad); primMap["sound"] = OSD.FromUUID(Prim.Sound); primMap["sound_flags"] = OSD.FromInteger((int)Prim.SoundFlags); primMap["sound_gain"] = OSD.FromReal(Prim.SoundGain); primMap["sound_radius"] = OSD.FromReal(Prim.SoundRadius); primMap["text"] = OSD.FromString(Prim.Text); primMap["text_color"] = OSD.FromColor4(Prim.TextColor); primMap["texture_anim"] = Prim.TextureAnim.GetOSD(); primMap["tree_species"] = OSD.FromInteger((int)Prim.TreeSpecies); primMap["velocity"] = OSD.FromVector3(Prim.Velocity); primMap["material"] = OSD.FromInteger((int)primData.Material); primMap["state"] = OSD.FromInteger(primData.State); primMap["pcode"] = OSD.FromInteger((int)primData.PCode); if (Prim.NameValues != null) primMap["name_values"] = OSD.FromString(NameValue.NameValuesToString(Prim.NameValues)); if (Prim.Textures != null) primMap["textures"] = Prim.Textures.GetOSD(); if (Prim.Light != null) primMap["light"] = Prim.Light.GetOSD(); if (Prim.Flexible != null) primMap["flex"] = Prim.Flexible.GetOSD(); if (Prim.Sculpt != null) primMap["sculpt"] = Prim.Sculpt.GetOSD(); OSDMap map = new OSDMap(); map["prim"] = primMap; map["sit_position"] = OSD.FromVector3(SitPosition); map["sit_rotation"] = OSD.FromQuaternion(SitRotation); map["attachment_position"] = OSD.FromVector3(AttachmentPosition); map["attachment_rotation"] = OSD.FromQuaternion(AttachmentRotation); map["last_attachment_point"] = OSD.FromInteger((int)LastAttachmentPoint); map["before_attachment_rotation"] = OSD.FromQuaternion(BeforeAttachmentRotation); map["rotation_axis"] = OSD.FromVector3(m_rotationAxis); map["link_number"] = OSD.FromInteger(m_linkNumber); map["remote_script_access_pin"] = OSD.FromInteger(RemoteScriptAccessPIN); map["inventory"] = OSD.FromString(Inventory.GetTaskInventoryAsset()); OSDArray buttons = new OSDArray { OSD.FromInteger(PayPriceButtons[0]), OSD.FromInteger(PayPriceButtons[1]), OSD.FromInteger(PayPriceButtons[2]), OSD.FromInteger(PayPriceButtons[3]) }; map["pay_price_buttons"] = buttons; map["pay_price"] = OSD.FromInteger(PayPrice); if (Prim.FaceMedia != null) { OSDArray faceMedia = new OSDArray(Prim.FaceMedia.Length); for (int i = 0; i < Prim.FaceMedia.Length; i++) { MediaEntry entry = Prim.FaceMedia[i]; if (entry != null) faceMedia.Add(entry.GetOSD()); else faceMedia.Add(new OSD()); } map["face_media"] = faceMedia; } map["media_version"] = OSD.FromString(Prim.MediaVersion); map["last_updated"] = OSD.FromDate(m_lastUpdated); return map; }