Difference between revisions of "LlDetectedTouchPos"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 18: Line 18:
default
default
{
{
     touch_start(integer pos_detected)
     touch_start(integer num_detected)
     {
     {
         integer i = 0;
         llWhisper(PUBLIC_CHANNEL, "Pos clicked: " + (string)llDetectedTouchPos(0));
        for(; i<pos_detected; ++i)
            llWhisper(0, "Pos clicked: " + (string)llDetectedTouchPos(i));
     }
     }
}
}
Line 29: Line 27:
vector GetRealTouchPos(vector pos)
vector GetRealTouchPos(vector pos)
{
{
    //By Ariu Arai for free use to anyone
// By Ariu Arai for free use to anyone
    //Returns a useful HUD Position Vector from the llDetectedTouchPos(); function
// Returns a useful HUD Position Vector from the llDetectedTouchPos(); function
    //USE: vector pos = GetRealTouchPos(llDetectedTouchPos(0)); .. Etc.
// USE: vector pos = GetRealTouchPos(llDetectedTouchPos(0)); .. Etc.
    //This function is intended to be used to move child prims to where the user clicks. This does not work on the root prim.
// This function is intended to be used to move child prims to where the user clicks. This does not work on the root prim.
 
     integer point = llGetAttached();
     integer point = llGetAttached();
     vector offset;
     vector offset;
 
     if(point == ATTACH_HUD_TOP_RIGHT)offset = <1, .933, -0.5>;
     if     (point == ATTACH_HUD_TOP_RIGHT)   offset = <1.0, 0.933,-0.5>;
     else if(point == ATTACH_HUD_TOP_CENTER)offset = <1, 0, -0.5>;
     else if (point == ATTACH_HUD_TOP_CENTER)   offset = <1.0, 0.000,-0.5>;
     else if(point == ATTACH_HUD_TOP_LEFT)offset = <1, -.933, -0.5>;
     else if (point == ATTACH_HUD_TOP_LEFT)     offset = <1.0,-0.933,-0.5>;
     else if(point == ATTACH_HUD_BOTTOM_LEFT)offset = <1, -.933, 0.5>;
     else if (point == ATTACH_HUD_BOTTOM_LEFT) offset = <1.0,-0.933, 0.5>;
     else if(point == ATTACH_HUD_BOTTOM)offset = <1, 0.0, 0.5>;
     else if (point == ATTACH_HUD_BOTTOM)       offset = <1.0, 0.000, 0.5>;
     else if(point == ATTACH_HUD_BOTTOM_RIGHT)offset = <1, .933, 0.5>;
     else if (point == ATTACH_HUD_BOTTOM_RIGHT) offset = <1.0, 0.933, 0.5>;
 
     //return (pos - llGetLocalPos()) + (offset * llGetLocalRot());
     //return (pos - llGetLocalPos()) + (offset * llGetLocalRot());
     return ((offset - llGetLocalPos()) + pos) / llGetLocalRot();
     return ((offset - llGetLocalPos()) + pos) / llGetLocalRot();

Revision as of 23:52, 8 October 2013

Summary

Function: vector llDetectedTouchPos( integer index );

Returns the vector position where the object was touched in region coordinates, unless it is attached to the HUD, in which case it returns the position in screen space coordinates.

• integer index Index of detection information

index does not support negative indexes. For the touch category of events only. The prim that was touched may not be the prim receiving the event, use llDetectedLinkNumber to check for this; likewise you can use llDetectedTouchFace to determine which face was touched.

Caveats

  • HUD attachments currently return coordinates relative to the center of the screen rather than the attachment point. SVC-3425
  • If index is out of bounds the script continues to execute without an error message.
  • TOUCH_INVALID_VECTOR is returned when...
    • The avatar's viewer does not support face touch detection.
    • The touch has moved off the surface of the prim.
    • The event triggered is not a touch event.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   For HUDs llDetectedTouchPos does not return positions relative to attach point, position is relative to screen center?

Examples

<lsl> default {

   touch_start(integer num_detected)
   {
       llWhisper(PUBLIC_CHANNEL, "Pos clicked: " + (string)llDetectedTouchPos(0));
   }

} </lsl> <lsl> vector GetRealTouchPos(vector pos) { // By Ariu Arai for free use to anyone // Returns a useful HUD Position Vector from the llDetectedTouchPos(); function // USE: vector pos = GetRealTouchPos(llDetectedTouchPos(0)); .. Etc. // This function is intended to be used to move child prims to where the user clicks. This does not work on the root prim.

   integer point = llGetAttached();
   vector offset;
   if      (point == ATTACH_HUD_TOP_RIGHT)    offset = <1.0, 0.933,-0.5>;
   else if (point == ATTACH_HUD_TOP_CENTER)   offset = <1.0, 0.000,-0.5>;
   else if (point == ATTACH_HUD_TOP_LEFT)     offset = <1.0,-0.933,-0.5>;
   else if (point == ATTACH_HUD_BOTTOM_LEFT)  offset = <1.0,-0.933, 0.5>;
   else if (point == ATTACH_HUD_BOTTOM)       offset = <1.0, 0.000, 0.5>;
   else if (point == ATTACH_HUD_BOTTOM_RIGHT) offset = <1.0, 0.933, 0.5>;
   //return (pos - llGetLocalPos()) + (offset * llGetLocalRot());
   return ((offset - llGetLocalPos()) + pos) / llGetLocalRot();

}

</lsl>

See Also

Deep Notes

History

All Issues

~ Search JIRA for related Issues
   For HUDs llDetectedTouchPos does not return positions relative to attach point, position is relative to screen center?

Signature

function vector llDetectedTouchPos( integer index );