diff options
author | Melanie Thielker | 2008-07-31 12:31:31 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-07-31 12:31:31 +0000 |
commit | c441a03ea3120c52af3fdffb284194f2609127cf (patch) | |
tree | 539b48d22ab51f45dc09f930dbeb1b7f6ba703a8 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Thank you, HomerHorwitz, for a patch that add PERMISSION_CONTROL_CAMERA (diff) | |
download | opensim-SC-c441a03ea3120c52af3fdffb284194f2609127cf.zip opensim-SC-c441a03ea3120c52af3fdffb284194f2609127cf.tar.gz opensim-SC-c441a03ea3120c52af3fdffb284194f2609127cf.tar.bz2 opensim-SC-c441a03ea3120c52af3fdffb284194f2609127cf.tar.xz |
Thank you, HomerHorwitz, for a patch that implements llSetCameraParams/llClearCameraParams.
Fixes Mantis #1867
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 68 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 24 |
2 files changed, 90 insertions, 2 deletions
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 | |||
6695 | public void llSetCameraParams(LSL_Types.list rules) | 6695 | public void llSetCameraParams(LSL_Types.list rules) |
6696 | { | 6696 | { |
6697 | m_host.AddScriptLPS(1); | 6697 | m_host.AddScriptLPS(1); |
6698 | NotImplemented("llSetCameraParams"); | 6698 | |
6699 | // our key in the object we are in | ||
6700 | LLUUID invItemID=InventorySelf(); | ||
6701 | if (invItemID == LLUUID.Zero) return; | ||
6702 | |||
6703 | // the object we are in | ||
6704 | LLUUID objectID = m_host.ParentUUID; | ||
6705 | if(objectID == LLUUID.Zero) return; | ||
6706 | |||
6707 | // we need the permission first, to know which avatar we want to set the camera for | ||
6708 | LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
6709 | if (agentID == LLUUID.Zero) return; | ||
6710 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
6711 | |||
6712 | ScenePresence presence = World.GetScenePresence(agentID); | ||
6713 | |||
6714 | // we are not interested in child-agents | ||
6715 | if(presence.IsChildAgent) return; | ||
6716 | |||
6717 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | ||
6718 | object[] data = rules.Data; | ||
6719 | for(int i = 0; i < data.Length; ++i) { | ||
6720 | int type = Convert.ToInt32(data[i++]); | ||
6721 | if(i >= data.Length) break; // odd number of entries => ignore the last | ||
6722 | |||
6723 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | ||
6724 | switch(type) { | ||
6725 | case ScriptBaseClass.CAMERA_FOCUS: | ||
6726 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | ||
6727 | case ScriptBaseClass.CAMERA_POSITION: | ||
6728 | LSL_Types.Vector3 v = (LSL_Types.Vector3)data[i]; | ||
6729 | parameters.Add(type + 1, (float)v.x); | ||
6730 | parameters.Add(type + 2, (float)v.y); | ||
6731 | parameters.Add(type + 3, (float)v.z); | ||
6732 | break; | ||
6733 | default: | ||
6734 | // TODO: clean that up as soon as the implicit casts are in | ||
6735 | if(data[i] is LSL_Types.LSLFloat) | ||
6736 | parameters.Add(type, (float)((LSL_Types.LSLFloat)data[i]).value); | ||
6737 | else if(data[i] is LSL_Types.LSLInteger) | ||
6738 | parameters.Add(type, (float)((LSL_Types.LSLInteger)data[i]).value); | ||
6739 | else parameters.Add(type, Convert.ToSingle(data[i])); | ||
6740 | break; | ||
6741 | } | ||
6742 | } | ||
6743 | if(parameters.Count > 0) presence.ControllingClient.SendSetFollowCamProperties(objectID, parameters); | ||
6699 | } | 6744 | } |
6700 | 6745 | ||
6701 | public void llClearCameraParams() | 6746 | public void llClearCameraParams() |
6702 | { | 6747 | { |
6703 | m_host.AddScriptLPS(1); | 6748 | m_host.AddScriptLPS(1); |
6704 | NotImplemented("llClearCameraParams"); | 6749 | |
6750 | // our key in the object we are in | ||
6751 | LLUUID invItemID=InventorySelf(); | ||
6752 | if (invItemID == LLUUID.Zero) return; | ||
6753 | |||
6754 | // the object we are in | ||
6755 | LLUUID objectID = m_host.ParentUUID; | ||
6756 | if(objectID == LLUUID.Zero) return; | ||
6757 | |||
6758 | // we need the permission first, to know which avatar we want to clear the camera for | ||
6759 | LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
6760 | if (agentID == LLUUID.Zero) return; | ||
6761 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
6762 | |||
6763 | ScenePresence presence = World.GetScenePresence(agentID); | ||
6764 | |||
6765 | // we are not interested in child-agents | ||
6766 | if(presence.IsChildAgent) return; | ||
6767 | |||
6768 | presence.ControllingClient.SendClearFollowCamProperties(objectID); | ||
6705 | } | 6769 | } |
6706 | 6770 | ||
6707 | public double llListStatistics(int operation, LSL_Types.list src) | 6771 | 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 | |||
421 | public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); | 421 | public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); |
422 | public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0); | 422 | public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0); |
423 | 423 | ||
424 | // constants for llSetCameraParams | ||
425 | public const int CAMERA_PITCH = 0; | ||
426 | public const int CAMERA_FOCUS_OFFSET = 1; | ||
427 | public const int CAMERA_FOCUS_OFFSET_X = 2; | ||
428 | public const int CAMERA_FOCUS_OFFSET_Y = 3; | ||
429 | public const int CAMERA_FOCUS_OFFSET_Z = 4; | ||
430 | public const int CAMERA_POSITION_LAG = 5; | ||
431 | public const int CAMERA_FOCUS_LAG = 6; | ||
432 | public const int CAMERA_DISTANCE = 7; | ||
433 | public const int CAMERA_BEHINDNESS_ANGLE = 8; | ||
434 | public const int CAMERA_BEHINDNESS_LAG = 9; | ||
435 | public const int CAMERA_POSITION_THRESHOLD = 10; | ||
436 | public const int CAMERA_FOCUS_THRESHOLD = 11; | ||
437 | public const int CAMERA_ACTIVE = 12; | ||
438 | public const int CAMERA_POSITION = 13; | ||
439 | public const int CAMERA_POSITION_X = 14; | ||
440 | public const int CAMERA_POSITION_Y = 15; | ||
441 | public const int CAMERA_POSITION_Z = 16; | ||
442 | public const int CAMERA_FOCUS = 17; | ||
443 | public const int CAMERA_FOCUS_X = 18; | ||
444 | public const int CAMERA_FOCUS_Y = 19; | ||
445 | public const int CAMERA_FOCUS_Z = 20; | ||
446 | public const int CAMERA_POSITION_LOCKED = 21; | ||
447 | public const int CAMERA_FOCUS_LOCKED = 22; | ||
424 | } | 448 | } |
425 | } | 449 | } |