diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs | 22 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 51 |
2 files changed, 73 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 20d8e54..fd62328 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs | |||
@@ -32,8 +32,30 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 33 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
34 | { | 34 | { |
35 | public class TouchEventArgs : EventArgs | ||
36 | { | ||
37 | public IAvatar Avatar; | ||
38 | |||
39 | public Vector3 TouchBiNormal; | ||
40 | public Vector3 TouchNormal; | ||
41 | public Vector3 TouchPosition; | ||
42 | |||
43 | public Vector2 TouchUV; | ||
44 | public Vector2 TouchST; | ||
45 | |||
46 | public int TouchMaterialIndex; | ||
47 | } | ||
48 | |||
49 | public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); | ||
50 | |||
35 | public interface IObject | 51 | public interface IObject |
36 | { | 52 | { |
53 | #region Events | ||
54 | |||
55 | event OnTouchDelegate OnTouch; | ||
56 | |||
57 | #endregion | ||
58 | |||
37 | /// <summary> | 59 | /// <summary> |
38 | /// Returns whether or not this object is still in the world. | 60 | /// Returns whether or not this object is still in the world. |
39 | /// Eg, if you store an IObject reference, however the object | 61 | /// Eg, if you store an IObject reference, however the object |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 48cae2f..4734fa9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -59,6 +59,57 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
59 | return null; | 59 | return null; |
60 | } | 60 | } |
61 | 61 | ||
62 | #region OnTouch | ||
63 | |||
64 | private event OnTouchDelegate _OnTouch; | ||
65 | private bool _OnTouchActive = false; | ||
66 | |||
67 | public event OnTouchDelegate OnTouch | ||
68 | { | ||
69 | add | ||
70 | { | ||
71 | if(!_OnTouchActive) | ||
72 | { | ||
73 | _OnTouchActive = true; | ||
74 | m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; | ||
75 | } | ||
76 | |||
77 | _OnTouch += value; | ||
78 | } | ||
79 | remove | ||
80 | { | ||
81 | _OnTouch -= value; | ||
82 | |||
83 | if (_OnTouch == null) | ||
84 | { | ||
85 | _OnTouchActive = false; | ||
86 | m_rootScene.EventManager.OnObjectGrab -= EventManager_OnObjectGrab; | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void EventManager_OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | ||
92 | { | ||
93 | if (_OnTouchActive && m_localID == localID) | ||
94 | { | ||
95 | TouchEventArgs e = new TouchEventArgs(); | ||
96 | e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); | ||
97 | e.TouchBiNormal = surfaceArgs.Binormal; | ||
98 | e.TouchMaterialIndex = surfaceArgs.FaceIndex; | ||
99 | e.TouchNormal = surfaceArgs.Normal; | ||
100 | e.TouchPosition = surfaceArgs.Position; | ||
101 | e.TouchST = new Vector2(surfaceArgs.STCoord.X, surfaceArgs.STCoord.Y); | ||
102 | e.TouchUV = new Vector2(surfaceArgs.UVCoord.X, surfaceArgs.UVCoord.Y); | ||
103 | |||
104 | IObject sender = this; | ||
105 | |||
106 | if (_OnTouch != null) | ||
107 | _OnTouch(sender, e); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | #endregion | ||
112 | |||
62 | public bool Exists | 113 | public bool Exists |
63 | { | 114 | { |
64 | get { return GetSOP() != null; } | 115 | get { return GetSOP() != null; } |