public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive prim, PrimFlags flags, uint crc) { byte[] objectData = new byte[60]; prim.Position.ToBytes(objectData, 0); prim.Velocity.ToBytes(objectData, 12); prim.Acceleration.ToBytes(objectData, 24); prim.Rotation.ToBytes(objectData, 36); prim.AngularVelocity.ToBytes(objectData, 48); ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); update.ClickAction = (byte)prim.ClickAction; update.CRC = crc; update.ExtraParams = prim.GetExtraParamsBytes(); update.Flags = (byte)flags; update.FullID = prim.ID; update.Gain = prim.SoundGain; update.ID = prim.LocalID; update.JointAxisOrAnchor = prim.JointAxisOrAnchor; update.JointPivot = prim.JointPivot; update.JointType = (byte)prim.Joint; update.Material = (byte)prim.PrimData.Material; update.MediaURL = Utils.StringToBytes(prim.MediaURL); update.NameValue = Utils.StringToBytes(NameValue.NameValuesToString(prim.NameValues)); update.ObjectData = objectData; update.OwnerID = (prim.Properties != null ? prim.Properties.OwnerID : UUID.Zero); update.ParentID = prim.ParentID; update.PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin); update.PathCurve = (byte)prim.PrimData.PathCurve; update.PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd); update.PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset); update.PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions); update.PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX); update.PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY); update.PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX); update.PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY); update.PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew); update.PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX); update.PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY); update.PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist); update.PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin); update.PCode = (byte)prim.PrimData.PCode; update.ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin); update.ProfileCurve = (byte)prim.PrimData.ProfileCurve; update.ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd); update.ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow); update.PSBlock = prim.ParticleSys.GetBytes(); update.TextColor = prim.TextColor.GetBytes(true); update.TextureAnim = prim.TextureAnim.GetBytes(); update.TextureEntry = prim.Textures == null ? Utils.EmptyBytes : prim.Textures.GetBytes(); update.Radius = prim.SoundRadius; update.Scale = prim.Scale; update.Sound = prim.Sound; update.State = prim.PrimData.State; update.Text = Utils.StringToBytes(prim.Text); update.UpdateFlags = (uint)flags; switch (prim.PrimData.PCode) { case PCode.Grass: case PCode.Tree: case PCode.NewTree: update.Data = new byte[1]; update.Data[0] = (byte)prim.TreeSpecies; break; default: if (prim.ScratchPad != null) { update.Data = new byte[prim.ScratchPad.Length]; Buffer.BlockCopy(prim.ScratchPad, 0, update.Data, 0, update.Data.Length); } else { update.Data = new byte[0]; } break; } return update; }
public static void WriteShape(XmlTextWriter writer, Primitive prim, Primitive.ObjectProperties props, Primitive.ConstructionData shp, ImportSettings options) { if (true /*shp != null*/) { writer.WriteStartElement("Shape"); WriteEnum(writer, "ProfileCurve", shp.ProfileCurve); writer.WriteStartElement("TextureEntry"); byte[] te; if (prim.Textures != null) te = prim.Textures.GetBytes(); else te = Utils.EmptyBytes; writer.WriteBase64(te, 0, te.Length); writer.WriteEndElement(); // TextureEntry writer.WriteStartElement("ExtraParams"); byte[] ep; if (prim.GetExtraParamsBytes() != null) ep = prim.GetExtraParamsBytes(); else ep = Utils.EmptyBytes; writer.WriteBase64(ep, 0, ep.Length); writer.WriteEndElement(); // ExtraParams writer.WriteElementString("PathBegin", Primitive.PackBeginCut(shp.PathBegin).ToString()); WriteEnum(writer, "PathCurve", shp.PathCurve); writer.WriteElementString("PathEnd", Primitive.PackEndCut(shp.PathEnd).ToString()); writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(shp.PathRadiusOffset).ToString()); writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(shp.PathRevolutions).ToString()); writer.WriteElementString("PathScaleX", Primitive.PackPathScale(shp.PathScaleX).ToString()); writer.WriteElementString("PathScaleY", Primitive.PackPathScale(shp.PathScaleY).ToString()); writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(shp.PathShearX)).ToString()); writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(shp.PathShearY)).ToString()); writer.WriteElementString("PathSkew", Primitive.PackPathTwist(shp.PathSkew).ToString()); writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(shp.PathTaperX).ToString()); writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(shp.PathTaperY).ToString()); writer.WriteElementString("PathTwist", Primitive.PackPathTwist(shp.PathTwist).ToString()); writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(shp.PathTwistBegin).ToString()); writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(shp.ProfileBegin).ToString()); writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(shp.ProfileEnd).ToString()); writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(shp.ProfileHollow).ToString()); WriteEnum(writer, "PCode", shp.PCode); // this is Attachment in a way? WriteInt(writer, "State", shp.State); //WriteEnum(writer, "State", shp.AttachmentPoint); WriteFlags(writer, "ProfileShape", shp.ProfileCurve, options); WriteFlags(writer, "HollowShape", shp.ProfileHole, options); var Sculpt = prim.Sculpt; if (Sculpt != null) { WriteUUID(writer, "SculptTexture", Sculpt.SculptTexture, options); WriteEnum(writer, "SculptType", Sculpt.Type); writer.WriteStartElement("SculptData"); byte[] sd; if (prim.Sculpt != null) sd = Sculpt.GetBytes(); else sd = Utils.EmptyBytes; writer.WriteBase64(sd, 0, sd.Length); writer.WriteEndElement(); // SculptData } Primitive.FlexibleData Flexi = prim.Flexible; if (Flexi != null) { WriteInt(writer,"FlexiSoftness", Flexi.Softness); WriteFloat(writer,"FlexiTension", Flexi.Tension); WriteFloat(writer,"FlexiDrag", Flexi.Drag); WriteFloat(writer,"FlexiGravity", Flexi.Gravity); WriteFloat(writer,"FlexiWind", Flexi.Wind); WriteFloat(writer,"FlexiForceX", Flexi.Force.X); WriteFloat(writer,"FlexiForceY", Flexi.Force.Y); WriteFloat(writer,"FlexiForceZ", Flexi.Force.Z); } Primitive.LightData Light = prim.Light; if (Light != null) { WriteFloat(writer,"LightColorR", Light.Color.R); WriteFloat(writer,"LightColorG", Light.Color.G); WriteFloat(writer,"LightColorB", Light.Color.B); WriteFloat(writer,"LightColorA", Light.Color.A); WriteFloat(writer,"LightRadius", Light.Radius); WriteFloat(writer,"LightCutoff", Light.Cutoff); WriteFloat(writer,"LightFalloff", Light.Falloff); WriteFloat(writer,"LightIntensity", Light.Intensity); } WriteValue(writer,"FlexiEntry", (Flexi != null).ToString().ToLower()); WriteValue(writer,"LightEntry", (Light != null).ToString().ToLower()); WriteValue(writer,"SculptEntry", (Sculpt != null).ToString().ToLower()); //todo if (shp.Media != null) WES(writer,"Media", shp.Media.ToXml()); writer.WriteEndElement(); // Shape } }
public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive obj, ulong regionHandle, 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 = obj.GetExtraParamsBytes(); 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 != null ? obj.Properties.OwnerID : UUID.Zero); 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 = obj.ParticleSys.GetBytes(); 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 = obj.PrimData.State; update.Text = Utils.StringToBytes(obj.Text); update.UpdateFlags = (uint)flags; update.Data = obj.GenericData == null ? new byte[0] : obj.GenericData; return update; }