From c441a03ea3120c52af3fdffb284194f2609127cf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 31 Jul 2008 12:31:31 +0000 Subject: Thank you, HomerHorwitz, for a patch that implements llSetCameraParams/llClearCameraParams. Fixes Mantis #1867 --- .../Shared/Api/Implementation/LSL_Api.cs | 68 +++++++++++++++++++++- .../Shared/Api/Runtime/LSL_Constants.cs | 24 ++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 99af529..dadad02 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6695,13 +6695,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetCameraParams(LSL_Types.list rules) { m_host.AddScriptLPS(1); - NotImplemented("llSetCameraParams"); + + // our key in the object we are in + LLUUID invItemID=InventorySelf(); + if (invItemID == LLUUID.Zero) return; + + // the object we are in + LLUUID objectID = m_host.ParentUUID; + if(objectID == LLUUID.Zero) return; + + // we need the permission first, to know which avatar we want to set the camera for + LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter; + if (agentID == LLUUID.Zero) return; + if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + + ScenePresence presence = World.GetScenePresence(agentID); + + // we are not interested in child-agents + if(presence.IsChildAgent) return; + + SortedDictionary parameters = new SortedDictionary(); + object[] data = rules.Data; + for(int i = 0; i < data.Length; ++i) { + int type = Convert.ToInt32(data[i++]); + if(i >= data.Length) break; // odd number of entries => ignore the last + + // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) + switch(type) { + case ScriptBaseClass.CAMERA_FOCUS: + case ScriptBaseClass.CAMERA_FOCUS_OFFSET: + case ScriptBaseClass.CAMERA_POSITION: + LSL_Types.Vector3 v = (LSL_Types.Vector3)data[i]; + parameters.Add(type + 1, (float)v.x); + parameters.Add(type + 2, (float)v.y); + parameters.Add(type + 3, (float)v.z); + break; + default: + // TODO: clean that up as soon as the implicit casts are in + if(data[i] is LSL_Types.LSLFloat) + parameters.Add(type, (float)((LSL_Types.LSLFloat)data[i]).value); + else if(data[i] is LSL_Types.LSLInteger) + parameters.Add(type, (float)((LSL_Types.LSLInteger)data[i]).value); + else parameters.Add(type, Convert.ToSingle(data[i])); + break; + } + } + if(parameters.Count > 0) presence.ControllingClient.SendSetFollowCamProperties(objectID, parameters); } public void llClearCameraParams() { m_host.AddScriptLPS(1); - NotImplemented("llClearCameraParams"); + + // our key in the object we are in + LLUUID invItemID=InventorySelf(); + if (invItemID == LLUUID.Zero) return; + + // the object we are in + LLUUID objectID = m_host.ParentUUID; + if(objectID == LLUUID.Zero) return; + + // we need the permission first, to know which avatar we want to clear the camera for + LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter; + if (agentID == LLUUID.Zero) return; + if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + + ScenePresence presence = World.GetScenePresence(agentID); + + // we are not interested in child-agents + if(presence.IsChildAgent) return; + + presence.ControllingClient.SendClearFollowCamProperties(objectID); } public double llListStatistics(int operation, LSL_Types.list src) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 810a655..3dc1c05 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -421,5 +421,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0); + // constants for llSetCameraParams + public const int CAMERA_PITCH = 0; + public const int CAMERA_FOCUS_OFFSET = 1; + public const int CAMERA_FOCUS_OFFSET_X = 2; + public const int CAMERA_FOCUS_OFFSET_Y = 3; + public const int CAMERA_FOCUS_OFFSET_Z = 4; + public const int CAMERA_POSITION_LAG = 5; + public const int CAMERA_FOCUS_LAG = 6; + public const int CAMERA_DISTANCE = 7; + public const int CAMERA_BEHINDNESS_ANGLE = 8; + public const int CAMERA_BEHINDNESS_LAG = 9; + public const int CAMERA_POSITION_THRESHOLD = 10; + public const int CAMERA_FOCUS_THRESHOLD = 11; + public const int CAMERA_ACTIVE = 12; + public const int CAMERA_POSITION = 13; + public const int CAMERA_POSITION_X = 14; + public const int CAMERA_POSITION_Y = 15; + public const int CAMERA_POSITION_Z = 16; + public const int CAMERA_FOCUS = 17; + public const int CAMERA_FOCUS_X = 18; + public const int CAMERA_FOCUS_Y = 19; + public const int CAMERA_FOCUS_Z = 20; + public const int CAMERA_POSITION_LOCKED = 21; + public const int CAMERA_FOCUS_LOCKED = 22; } } -- cgit v1.1