aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authoridb2008-12-05 16:48:47 +0000
committeridb2008-12-05 16:48:47 +0000
commit7ae9ec217d6e1ec039fbd6ed16c952d56cc63dc6 (patch)
tree6fed56271b075ef0c9c42e3cc899e86e54ea4c25 /OpenSim/Region/ScriptEngine
parentFixed Mantis #2756 (diff)
downloadopensim-SC_OLD-7ae9ec217d6e1ec039fbd6ed16c952d56cc63dc6.zip
opensim-SC_OLD-7ae9ec217d6e1ec039fbd6ed16c952d56cc63dc6.tar.gz
opensim-SC_OLD-7ae9ec217d6e1ec039fbd6ed16c952d56cc63dc6.tar.bz2
opensim-SC_OLD-7ae9ec217d6e1ec039fbd6ed16c952d56cc63dc6.tar.xz
Implementation of the llDetectedTouch* functions
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs54
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs58
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs7
5 files changed, 115 insertions, 15 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index 72766a4..09dbc40 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
141 } 141 }
142 142
143 public void touch_start(uint localID, uint originalID, 143 public void touch_start(uint localID, uint originalID,
144 Vector3 offsetPos, IClientAPI remoteClient) 144 Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
145 { 145 {
146 // Add to queue for all scripts in ObjectID object 146 // Add to queue for all scripts in ObjectID object
147 DetectParams[] det = new DetectParams[1]; 147 DetectParams[] det = new DetectParams[1];
@@ -165,6 +165,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
165 myScriptEngine.World.GetSceneObjectPart(originalID); 165 myScriptEngine.World.GetSceneObjectPart(originalID);
166 det[0].LinkNum = originalPart.LinkNum; 166 det[0].LinkNum = originalPart.LinkNum;
167 } 167 }
168 if (surfaceArgs != null)
169 {
170 det[0].SurfaceTouchArgs = surfaceArgs;
171 }
168 172
169 myScriptEngine.PostObjectEvent(localID, new EventParams( 173 myScriptEngine.PostObjectEvent(localID, new EventParams(
170 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, 174 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7a7c8d6..f98a9bb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -889,46 +889,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
889 return new LSL_Integer(parms.LinkNum); 889 return new LSL_Integer(parms.LinkNum);
890 } 890 }
891 891
892 /// <summary>
893 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchBinormal for details
894 /// </summary>
892 public LSL_Vector llDetectedTouchBinormal(int index) 895 public LSL_Vector llDetectedTouchBinormal(int index)
893 { 896 {
894 m_host.AddScriptLPS(1); 897 m_host.AddScriptLPS(1);
895 NotImplemented("llDetectedTouchBinormal"); 898 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
896 return new LSL_Vector(); 899 if (detectedParams == null || detectedParams.TouchBinormal == null)
900 return new LSL_Vector();
901 return detectedParams.TouchBinormal;
897 } 902 }
898 903
904 /// <summary>
905 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchFace for details
906 /// </summary>
899 public LSL_Integer llDetectedTouchFace(int index) 907 public LSL_Integer llDetectedTouchFace(int index)
900 { 908 {
901 m_host.AddScriptLPS(1); 909 m_host.AddScriptLPS(1);
902 NotImplemented("llDetectedTouchFace"); 910 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
903 return new LSL_Integer(0); 911 if (detectedParams == null || detectedParams.TouchFace == null)
912 return new LSL_Integer(-1);
913 return new LSL_Integer(detectedParams.TouchFace);
904 } 914 }
905 915
916 /// <summary>
917 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchNormal for details
918 /// </summary>
906 public LSL_Vector llDetectedTouchNormal(int index) 919 public LSL_Vector llDetectedTouchNormal(int index)
907 { 920 {
908 m_host.AddScriptLPS(1); 921 m_host.AddScriptLPS(1);
909 NotImplemented("llDetectedTouchNormal"); 922 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
910 return new LSL_Vector(); 923 if (detectedParams == null || detectedParams.TouchNormal == null)
924 return new LSL_Vector();
925 return detectedParams.TouchNormal;
911 } 926 }
912 927
928 /// <summary>
929 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchPos for details
930 /// </summary>
913 public LSL_Vector llDetectedTouchPos(int index) 931 public LSL_Vector llDetectedTouchPos(int index)
914 { 932 {
915 m_host.AddScriptLPS(1); 933 m_host.AddScriptLPS(1);
916 NotImplemented("llDetectedTouchPos"); 934 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
917 return new LSL_Vector(); 935 if (detectedParams == null || detectedParams.TouchPos == null)
936 return new LSL_Vector();
937 return detectedParams.TouchPos;
918 } 938 }
919 939
940 /// <summary>
941 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchST for details
942 /// </summary>
920 public LSL_Vector llDetectedTouchST(int index) 943 public LSL_Vector llDetectedTouchST(int index)
921 { 944 {
922 m_host.AddScriptLPS(1); 945 m_host.AddScriptLPS(1);
923 NotImplemented("llDetectedTouchST"); 946 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
924 return new LSL_Vector(); 947 if (detectedParams == null || detectedParams.TouchST == null)
948 return new LSL_Vector(-1.0, -1.0, 0.0);
949 return detectedParams.TouchST;
925 } 950 }
926 951
952 /// <summary>
953 /// See http://wiki.secondlife.com/wiki/LlDetectedTouchUV for details
954 /// </summary>
927 public LSL_Vector llDetectedTouchUV(int index) 955 public LSL_Vector llDetectedTouchUV(int index)
928 { 956 {
929 m_host.AddScriptLPS(1); 957 m_host.AddScriptLPS(1);
930 NotImplemented("llDetectedTouchUV"); 958 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
931 return new LSL_Vector(); 959 if (detectedParams == null || detectedParams.TouchUV == null)
960 return new LSL_Vector(-1.0, -1.0, 0.0);
961 return detectedParams.TouchUV;
932 } 962 }
933 963
934 public void llDie() 964 public void llDie()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index e087ea2..b97ec99 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -494,5 +494,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
494 public const int CLICK_ACTION_OPEN = 4; 494 public const int CLICK_ACTION_OPEN = 4;
495 public const int CLICK_ACTION_PLAY = 5; 495 public const int CLICK_ACTION_PLAY = 5;
496 public const int CLICK_ACTION_OPEN_MEDIA = 6; 496 public const int CLICK_ACTION_OPEN_MEDIA = 6;
497
498 // constants for the llDetectedTouch* functions
499 public const int TOUCH_INVALID_FACE = -1;
500 public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
501 public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
497 } 502 }
498} 503}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index a061fde..b9ff0cd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -80,6 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
80 Rotation = new LSL_Types.Quaternion(); 80 Rotation = new LSL_Types.Quaternion();
81 Type = 0; 81 Type = 0;
82 Velocity = new LSL_Types.Vector3(); 82 Velocity = new LSL_Types.Vector3();
83 initializeSurfaceTouch();
83 } 84 }
84 85
85 public UUID Key; 86 public UUID Key;
@@ -93,6 +94,61 @@ namespace OpenSim.Region.ScriptEngine.Shared
93 public int Type; 94 public int Type;
94 public LSL_Types.Vector3 Velocity; 95 public LSL_Types.Vector3 Velocity;
95 96
97 private LSL_Types.Vector3 touchST;
98 public LSL_Types.Vector3 TouchST { get { return touchST; } }
99
100 private LSL_Types.Vector3 touchNormal;
101 public LSL_Types.Vector3 TouchNormal { get { return touchNormal; } }
102
103 private LSL_Types.Vector3 touchBinormal;
104 public LSL_Types.Vector3 TouchBinormal { get { return touchBinormal; } }
105
106 private LSL_Types.Vector3 touchPos;
107 public LSL_Types.Vector3 TouchPos { get { return touchPos; } }
108
109 private LSL_Types.Vector3 touchUV;
110 public LSL_Types.Vector3 TouchUV { get { return touchUV; } }
111
112 private int touchFace;
113 public int TouchFace { get { return touchFace; } }
114
115 // This can be done in two places including the constructor
116 // so be carefull what gets added here
117 private void initializeSurfaceTouch()
118 {
119 touchST = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
120 touchNormal = new LSL_Types.Vector3();
121 touchBinormal = new LSL_Types.Vector3();
122 touchPos = new LSL_Types.Vector3();
123 touchUV = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
124 touchFace = -1;
125 }
126
127 /*
128 * Set up the surface touch detected values
129 */
130 public SurfaceTouchEventArgs SurfaceTouchArgs
131 {
132 set
133 {
134 if (value == null)
135 {
136 // Initialise to defaults if no value
137 initializeSurfaceTouch();
138 }
139 else
140 {
141 // Set the values from the touch data provided by the client
142 touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z);
143 touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z);
144 touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z);
145 touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z);
146 touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z);
147 touchFace = value.FaceIndex;
148 }
149 }
150 }
151
96 public void Populate(Scene scene) 152 public void Populate(Scene scene)
97 { 153 {
98 SceneObjectPart part = scene.GetSceneObjectPart(Key); 154 SceneObjectPart part = scene.GetSceneObjectPart(Key);
@@ -177,4 +233,4 @@ namespace OpenSim.Region.ScriptEngine.Shared
177 public Object[] Params; 233 public Object[] Params;
178 public DetectParams[] DetectParams; 234 public DetectParams[] DetectParams;
179 } 235 }
180} \ No newline at end of file 236}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 9ed2fbb..67ac0ce 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
80 } 80 }
81 81
82 public void touch_start(uint localID, uint originalID, Vector3 offsetPos, 82 public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
83 IClientAPI remoteClient) 83 IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
84 { 84 {
85 // Add to queue for all scripts in ObjectID object 85 // Add to queue for all scripts in ObjectID object
86 DetectParams[] det = new DetectParams[1]; 86 DetectParams[] det = new DetectParams[1];
@@ -102,6 +102,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
102 det[0].LinkNum = originalPart.LinkNum; 102 det[0].LinkNum = originalPart.LinkNum;
103 } 103 }
104 104
105 if (surfaceArgs != null)
106 {
107 det[0].SurfaceTouchArgs = surfaceArgs;
108 }
109
105 myScriptEngine.PostObjectEvent(localID, new EventParams( 110 myScriptEngine.PostObjectEvent(localID, new EventParams(
106 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, 111 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
107 det)); 112 det));