private void SendChildUpdate(IScenePresence presence) { const float DEFAULT_DRAW_DISTANCE = 128.0f; // Build the template child_avatar/update message OSDMap childUpdate = new OSDMap(); childUpdate["agent_id"] = OSD.FromUUID(presence.ID); childUpdate["rotation"] = OSD.FromQuaternion(presence.SceneRotation); float drawDistance = DEFAULT_DRAW_DISTANCE; if (presence is LLAgent) { LLAgent agent = (LLAgent)presence; drawDistance = agent.DrawDistance; childUpdate["camera_center"] = OSD.FromVector3(agent.CameraPosition); childUpdate["camera_at"] = OSD.FromVector3(agent.CameraAtAxis); childUpdate["camera_left"] = OSD.FromVector3(agent.CameraLeftAxis); childUpdate["camera_up"] = OSD.FromVector3(agent.CameraUpAxis); } childUpdate["draw_distance"] = OSD.FromReal(drawDistance); // Get a list of neighbors to send this update to based on the draw distance SceneInfo[] neighbors = m_scene.GetNeighborsNear(m_scene.MinPosition + new Vector3d(presence.ScenePosition), drawDistance); for (int i = 0; i < neighbors.Length; i++) { SceneInfo neighbor = neighbors[i]; // Find the presence position relative to this neighbor Vector3 relativePosition = presence.ScenePosition - new Vector3(neighbor.MinPosition - presence.Scene.MinPosition); childUpdate["position"] = OSD.FromVector3(relativePosition); Uri childUpdateCap; if (neighbor.TryGetCapability("child_avatar/update", out childUpdateCap)) { try { // Send the message //m_log.Debug("Sending child agent update for " + presence.Name); string message = OSDParser.SerializeJsonString(childUpdate); UntrustedHttpWebRequest.PostToUntrustedUrl(childUpdateCap, message); } catch (Exception ex) { m_log.Warn("child_avatar/update from " + m_scene.Name + " to " + neighbor.Name + " for agent " + presence.Name + " failed: " + ex.Message); } } else { // This shouldn't happen since we check for the child_avatar/update capability // before adding this agent/neighbor pair to the queue throw new InvalidOperationException("child_avatar/update capability not found in SendChildUpdate handler"); } } }
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; }
public virtual OSD GetOSD() { OSDMap path = new OSDMap(14); path["begin"] = OSD.FromReal(PrimData.PathBegin); path["curve"] = OSD.FromInteger((int)PrimData.PathCurve); path["end"] = OSD.FromReal(PrimData.PathEnd); path["radius_offset"] = OSD.FromReal(PrimData.PathRadiusOffset); path["revolutions"] = OSD.FromReal(PrimData.PathRevolutions); path["scale_x"] = OSD.FromReal(PrimData.PathScaleX); path["scale_y"] = OSD.FromReal(PrimData.PathScaleY); path["shear_x"] = OSD.FromReal(PrimData.PathShearX); path["shear_y"] = OSD.FromReal(PrimData.PathShearY); path["skew"] = OSD.FromReal(PrimData.PathSkew); path["taper_x"] = OSD.FromReal(PrimData.PathTaperX); path["taper_y"] = OSD.FromReal(PrimData.PathTaperY); path["twist"] = OSD.FromReal(PrimData.PathTwist); path["twist_begin"] = OSD.FromReal(PrimData.PathTwistBegin); OSDMap profile = new OSDMap(4); profile["begin"] = OSD.FromReal(PrimData.ProfileBegin); profile["curve"] = OSD.FromInteger((int)PrimData.ProfileCurve); profile["hole"] = OSD.FromInteger((int)PrimData.ProfileHole); profile["end"] = OSD.FromReal(PrimData.ProfileEnd); profile["hollow"] = OSD.FromReal(PrimData.ProfileHollow); OSDMap volume = new OSDMap(2); volume["path"] = path; volume["profile"] = profile; OSDMap prim = new OSDMap(9); if (Properties != null) { prim["name"] = OSD.FromString(Properties.Name); prim["description"] = OSD.FromString(Properties.Description); } else { prim["name"] = OSD.FromString("Object"); prim["description"] = OSD.FromString(String.Empty); } prim["phantom"] = OSD.FromBoolean(((Flags & PrimFlags.Phantom) != 0)); prim["physical"] = OSD.FromBoolean(((Flags & PrimFlags.Physics) != 0)); prim["position"] = OSD.FromVector3(Position); prim["rotation"] = OSD.FromQuaternion(Rotation); prim["scale"] = OSD.FromVector3(Scale); prim["material"] = OSD.FromInteger((int)PrimData.Material); prim["shadows"] = OSD.FromBoolean(((Flags & PrimFlags.CastShadows) != 0)); prim["parentid"] = OSD.FromInteger(ParentID); prim["volume"] = volume; if (Textures != null) { prim["textures"] = Textures.GetOSD(); } if (Light != null) { prim["light"] = Light.GetOSD(); } if (Flexible != null) { prim["flex"] = Flexible.GetOSD(); } if (Sculpt != null) { prim["sculpt"] = Sculpt.GetOSD(); } return(prim); }
/// <summary> /// Convert the value of the given property to OSD type. /// </summary> /// <param name="property"></param> /// <returns></returns> public OSDArray ToOSDArray() { //DebugLog.WarnFormat("[SYNCED PROPERTY] ToOSDArray called for property {0}", Property.ToString()); lock (m_lock) { OSDArray propertyData = new OSDArray(); propertyData.Add(OSD.FromInteger((uint)Property)); propertyData.Add(OSD.FromLong(LastUpdateTimeStamp)); propertyData.Add(OSD.FromString(LastUpdateSyncID)); OSD value = null; switch (Property) { /////////////////////////////////////// //SOP properties with complex structure /////////////////////////////////////// case SyncableProperties.Type.AgentCircuitData: case SyncableProperties.Type.AvatarAppearance: value = (OSDMap)LastUpdateValue; break; case SyncableProperties.Type.Animations: value = (OSDArray)LastUpdateValue; break; //////////////////////////// // Integer/enum type properties //////////////////////////// case SyncableProperties.Type.CreationDate: // int case SyncableProperties.Type.LinkNum: // int case SyncableProperties.Type.OwnershipCost: // int case SyncableProperties.Type.SalePrice: // int case SyncableProperties.Type.ScriptAccessPin: // int case SyncableProperties.Type.AggregateScriptEvents: // enum case SyncableProperties.Type.Flags: // enum case SyncableProperties.Type.LocalFlags: // enum case SyncableProperties.Type.PresenceType: // enum value = OSD.FromInteger((int)LastUpdateValue); break; //////////////////////////// // Byte type properties //////////////////////////// case SyncableProperties.Type.ClickAction: case SyncableProperties.Type.Material: case SyncableProperties.Type.ObjectSaleType: value = OSD.FromInteger((byte)LastUpdateValue); break; //////////////////////////// // Boolean type properties //////////////////////////// case SyncableProperties.Type.AllowedDrop: case SyncableProperties.Type.IsAttachment: case SyncableProperties.Type.PassTouches: case SyncableProperties.Type.VolumeDetectActive: case SyncableProperties.Type.Flying: case SyncableProperties.Type.IsColliding: case SyncableProperties.Type.CollidingGround: case SyncableProperties.Type.Kinematic: case SyncableProperties.Type.IsSelected: case SyncableProperties.Type.AllowMovement: value = OSD.FromBoolean((bool)LastUpdateValue); break; //////////////////////////// // Vector3 type properties //////////////////////////// case SyncableProperties.Type.AngularVelocity: case SyncableProperties.Type.AttachedPos: case SyncableProperties.Type.GroupPosition: case SyncableProperties.Type.OffsetPosition: case SyncableProperties.Type.Scale: case SyncableProperties.Type.SitTargetPosition: case SyncableProperties.Type.SitTargetPositionLL: case SyncableProperties.Type.SOP_Acceleration: case SyncableProperties.Type.Velocity: case SyncableProperties.Type.Force: case SyncableProperties.Type.PA_Acceleration: case SyncableProperties.Type.PA_Velocity: case SyncableProperties.Type.PA_TargetVelocity: case SyncableProperties.Type.Position: case SyncableProperties.Type.RotationalVelocity: case SyncableProperties.Type.Size: case SyncableProperties.Type.Torque: case SyncableProperties.Type.AbsolutePosition: value = OSD.FromVector3((Vector3)LastUpdateValue); break; //////////////////////////// // UUID type properties //////////////////////////// case SyncableProperties.Type.AttachedAvatar: case SyncableProperties.Type.CollisionSound: case SyncableProperties.Type.CreatorID: case SyncableProperties.Type.FolderID: case SyncableProperties.Type.GroupID: case SyncableProperties.Type.LastOwnerID: case SyncableProperties.Type.OwnerID: case SyncableProperties.Type.Sound: value = OSD.FromUUID((UUID)LastUpdateValue); break; //////////////////////////// // UInt type properties //////////////////////////// case SyncableProperties.Type.LocalId: case SyncableProperties.Type.AttachmentPoint: case SyncableProperties.Type.BaseMask: case SyncableProperties.Type.Category: case SyncableProperties.Type.EveryoneMask: case SyncableProperties.Type.GroupMask: case SyncableProperties.Type.InventorySerial: case SyncableProperties.Type.NextOwnerMask: case SyncableProperties.Type.OwnerMask: case SyncableProperties.Type.AgentControlFlags: case SyncableProperties.Type.ParentId: value = OSD.FromUInteger((uint)LastUpdateValue); break; //////////////////////////// // Float type properties //////////////////////////// case SyncableProperties.Type.CollisionSoundVolume: case SyncableProperties.Type.Buoyancy: value = OSD.FromReal((float)LastUpdateValue); break; //////////////////////////// // String type properties //////////////////////////// case SyncableProperties.Type.Color: case SyncableProperties.Type.CreatorData: case SyncableProperties.Type.Description: case SyncableProperties.Type.MediaUrl: case SyncableProperties.Type.Name: case SyncableProperties.Type.RealRegion: case SyncableProperties.Type.Shape: case SyncableProperties.Type.SitName: case SyncableProperties.Type.TaskInventory: case SyncableProperties.Type.Text: case SyncableProperties.Type.TouchName: value = OSD.FromString((string)LastUpdateValue); break; //////////////////////////// // byte[] (binary data) type properties //////////////////////////// case SyncableProperties.Type.ParticleSystem: case SyncableProperties.Type.TextureAnimation: value = OSD.FromBinary((byte[])LastUpdateValue); break; //////////////////////////// // Quaternion type properties //////////////////////////// case SyncableProperties.Type.RotationOffset: case SyncableProperties.Type.SitTargetOrientation: case SyncableProperties.Type.SitTargetOrientationLL: case SyncableProperties.Type.Orientation: case SyncableProperties.Type.Rotation: value = OSD.FromQuaternion((Quaternion)LastUpdateValue); break; default: DebugLog.WarnFormat("[SYNCED PROPERTY] ToOSDArray: No handler for property {0} ", Property); break; } propertyData.Add(value); return(propertyData); } }