Implementation of the llDetectedTouch* functions

This commit is contained in:
idb
2008-12-05 16:48:47 +00:00
parent c826570751
commit 7ae9ec217d
8 changed files with 129 additions and 22 deletions

View File

@@ -889,46 +889,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Integer(parms.LinkNum);
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchBinormal for details
/// </summary>
public LSL_Vector llDetectedTouchBinormal(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchBinormal");
return new LSL_Vector();
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchBinormal == null)
return new LSL_Vector();
return detectedParams.TouchBinormal;
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchFace for details
/// </summary>
public LSL_Integer llDetectedTouchFace(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchFace");
return new LSL_Integer(0);
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchFace == null)
return new LSL_Integer(-1);
return new LSL_Integer(detectedParams.TouchFace);
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchNormal for details
/// </summary>
public LSL_Vector llDetectedTouchNormal(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchNormal");
return new LSL_Vector();
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchNormal == null)
return new LSL_Vector();
return detectedParams.TouchNormal;
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchPos for details
/// </summary>
public LSL_Vector llDetectedTouchPos(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchPos");
return new LSL_Vector();
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchPos == null)
return new LSL_Vector();
return detectedParams.TouchPos;
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchST for details
/// </summary>
public LSL_Vector llDetectedTouchST(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchST");
return new LSL_Vector();
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchST == null)
return new LSL_Vector(-1.0, -1.0, 0.0);
return detectedParams.TouchST;
}
/// <summary>
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchUV for details
/// </summary>
public LSL_Vector llDetectedTouchUV(int index)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedTouchUV");
return new LSL_Vector();
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
if (detectedParams == null || detectedParams.TouchUV == null)
return new LSL_Vector(-1.0, -1.0, 0.0);
return detectedParams.TouchUV;
}
public void llDie()

View File

@@ -494,5 +494,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int CLICK_ACTION_OPEN = 4;
public const int CLICK_ACTION_PLAY = 5;
public const int CLICK_ACTION_OPEN_MEDIA = 6;
// constants for the llDetectedTouch* functions
public const int TOUCH_INVALID_FACE = -1;
public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
}
}

View File

@@ -80,6 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
Rotation = new LSL_Types.Quaternion();
Type = 0;
Velocity = new LSL_Types.Vector3();
initializeSurfaceTouch();
}
public UUID Key;
@@ -93,6 +94,61 @@ namespace OpenSim.Region.ScriptEngine.Shared
public int Type;
public LSL_Types.Vector3 Velocity;
private LSL_Types.Vector3 touchST;
public LSL_Types.Vector3 TouchST { get { return touchST; } }
private LSL_Types.Vector3 touchNormal;
public LSL_Types.Vector3 TouchNormal { get { return touchNormal; } }
private LSL_Types.Vector3 touchBinormal;
public LSL_Types.Vector3 TouchBinormal { get { return touchBinormal; } }
private LSL_Types.Vector3 touchPos;
public LSL_Types.Vector3 TouchPos { get { return touchPos; } }
private LSL_Types.Vector3 touchUV;
public LSL_Types.Vector3 TouchUV { get { return touchUV; } }
private int touchFace;
public int TouchFace { get { return touchFace; } }
// This can be done in two places including the constructor
// so be carefull what gets added here
private void initializeSurfaceTouch()
{
touchST = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
touchNormal = new LSL_Types.Vector3();
touchBinormal = new LSL_Types.Vector3();
touchPos = new LSL_Types.Vector3();
touchUV = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
touchFace = -1;
}
/*
* Set up the surface touch detected values
*/
public SurfaceTouchEventArgs SurfaceTouchArgs
{
set
{
if (value == null)
{
// Initialise to defaults if no value
initializeSurfaceTouch();
}
else
{
// Set the values from the touch data provided by the client
touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z);
touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z);
touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z);
touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z);
touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z);
touchFace = value.FaceIndex;
}
}
}
public void Populate(Scene scene)
{
SceneObjectPart part = scene.GetSceneObjectPart(Key);
@@ -177,4 +233,4 @@ namespace OpenSim.Region.ScriptEngine.Shared
public Object[] Params;
public DetectParams[] DetectParams;
}
}
}