Difference between revisions of "LlDetectedTouchUV"

From Second Life Wiki
Jump to navigation Jump to search
(pie will be fixed, document touch behavior)
m
(36 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{LSL_Function/detected|index|TouchUV}}{{LSL_Function
{{LSL_Function
|inject-2={{LSL_Function/detected|index|touchUV|simple=*}}
|func_id=337|func_sleep=0.0|func_energy=10.0
|func_id=337|func_sleep=0.0|func_energy=10.0
|mode=pre-release
|func=llDetectedTouchUV
|func=llDetectedTouchUV
|return_type=vector|return_text=that is the texture coordinates for where the prim was touched. The x & y vector positions contain the u & v face coordinates respectively ('''{{NoWrap|{{LSL_VR|u|v|0.0}}}}''').
|return_type=vector|return_text=that is the texture coordinates for where the prim was touched. The {{LSLP|x}} & {{LSLP|y}} vector positions contain the horizontal ({{LSLP|u}}) & vertical ({{LSLP|v}}) texture coordinates respectively (<code>{{NoWrap|{{LSL_VR|{{LSLPT|u}}|{{LSLPT|v}}|0.0}}}}</code>). Like [[llDetectedTouchST]], the interval of each component will be {{Interval|gte=0.0|center=component|lte=1.0}} unless the texture repeats are set to a non-default value. Increasing or decreasing the texture repeats of the face will change this interval accordingly. Additionally,  unlike with [[llDetectedTouchST]], changing a texture's rotation will change the results of this function.


Inside [[touch_start]], returns <-1., -1., 0.> if the avatar's viewer does not support this feature.
{{LSL Const|TOUCH_INVALID_TEXCOORD|vector|{{LSL_VR|-1.0|-1.0|0.0}}}} is returned when the touch UV coordinates cannot be determined. See [[#Caveats|Caveats]] for further details.
Inside [[touch]], returns <-1., -1., 0.> if the mouse has moved away from the prim.
|p1_type=integer|p1_name=index
|p1_type=integer|p1_name=index
|func_footnote=For the {{LSLGC|Touch|touch}} category of events only.
|func_footnote=For the {{LSLGC|Touch|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.
|func_desc
|func_desc
|spec
|spec=
|caveats=* <-1., -1., 0.> can be returned for a touch just outside the prim edge. To tell this case apart from an unsupported viewer, check if [[llDetectedTouchFace]] returns -1 or a valid face.
|caveats=
|examples
*{{LSL Const|TOUCH_INVALID_TEXCOORD|vector|{{LSL_VR|-1.0|-1.0|0.0}}}} is returned when...
** The avatar's viewer does not support face touch detection.
*** To check if face touch detection is supported check the return of [[llDetectedTouchFace]].
** The touch has moved off the surface of the prim.
** The touch happened too close to the edge of the face to determine a location.
** The event triggered is not a {{LSLGC|Touch|touch}} event.
|examples=
<source lang="lsl2">
default
{
    touch_start(integer total_number)
    {
        integer face = llDetectedTouchFace(0);
        vector  touchUV  = llDetectedTouchUV(0);
 
//      ZERO_VECTOR (<0.0, 0.0, 0.0> ... the origin) is in the bottom left corner of the texture
//      touchUV.x goes across the texture from left to right
//      touchUV.y goes up the texture from bottom to top
 
        if (face == TOUCH_INVALID_FACE)
            llWhisper(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
        else if (touchUV == TOUCH_INVALID_TEXCOORD)
            llWhisper(PUBLIC_CHANNEL, "Sorry, the touch position upon the texture could not be determined.");
        else
            llSay(PUBLIC_CHANNEL, "llDetectedTouchUV(" + (string)touchUV + ")"
                    + "\ntouchUV.x = " + (string)touchUV.x
                    + "\ntouchUV.y = " + (string)touchUV.y);
    }
}
</source>
<source lang="lsl2">
integer numberOfRows    = 12;
integer numberOfColumns = 12;
 
default
{
    touch_start(integer num_detected)
    {
        vector touchUV = llDetectedTouchUV(0);
 
//      ZERO_VECTOR (<0.0, 0.0, 0.0> ... the origin) is in the bottom left corner of the texture
//      touchUV.x goes across the texture from left to right
//      touchUV.y goes up the texture from bottom to top
 
        integer columnIndex = (integer) (touchUV.x * numberOfColumns);
        integer rowIndex    = (integer) (touchUV.y * numberOfRows);
        integer cellIndex  = rowIndex * numberOfColumns + columnIndex;
 
        llSay(PUBLIC_CHANNEL, "UV grid (" + (string)columnIndex + ", " + (string)rowIndex + ") --> cell " + (string)cellIndex);
    }
}
</source>
|helpers
|helpers
|related
|related
Line 20: Line 70:
{{LSL DefineRow||[[llDetectedTouchST]]}}
{{LSL DefineRow||[[llDetectedTouchST]]}}
{{LSL DefineRow||[[llDetectedTouchPos]]}}
{{LSL DefineRow||[[llDetectedTouchPos]]}}
{{LSL DefineRow||[[llDetectedTouchNormal]]}}
{{LSL DefineRow||[[llDetectedTouchBinormal]]}}
|also_events=
|also_events=
{{LSL DefineRow||[[touch_start]]|}}
{{LSL DefineRow||[[touch_start]]|}}
Line 26: Line 78:
|also_articles
|also_articles
|notes
|notes
|history=*Introduced in Viewer {{SVN|870|rev=92872|branch=Release|anchor=file14|date=Wednesday, 23 July 2008}}, no server support, no viewer binary released.
|history=*Introduced in {{SVN|870|rev=92872|trunk=*|anchor=file14|date=Wednesday, 23 July 2008}}.
*Server support available on preview grid in Second Life Beta Server 1.24, client support in Preview Grid viewer 1.20.15 (93532)
*Date of Release Server [[ Release_Notes/Second_Life_Beta_Server/1.24#Release_Notes_for_Second_Life_Beta_Server_1.24.3_.28August_29th.2C_2008.29 | 29-08-2008 ]]
*Date of Release Client  [[ Release_Notes/Second_Life_Release/1.21 | 16-10-2008 ]]
*Server support available in Second Life Server 1.24.7.98039, client support in Release Candidate viewer 1.21.4 (98167).
|cat1=Touch
|cat1=Touch
|cat2
|cat2

Revision as of 01:01, 22 January 2015

Summary

Function: vector llDetectedTouchUV( integer index );

Returns a vector that is the texture coordinates for where the prim was touched. The x & y vector positions contain the horizontal (u) & vertical (v) texture coordinates respectively (<u, v, 0.0>). Like llDetectedTouchST, the interval of each component will be [0.0, 1.0] unless the texture repeats are set to a non-default value. Increasing or decreasing the texture repeats of the face will change this interval accordingly. Additionally, unlike with llDetectedTouchST, changing a texture's rotation will change the results of this function.

TOUCH_INVALID_TEXCOORD is returned when the touch UV coordinates cannot be determined. See Caveats for further details.

• 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

  • If index is out of bounds the script continues to execute without an error message.
  • TOUCH_INVALID_TEXCOORD is returned when...
    • The avatar's viewer does not support face touch detection.
    • The touch has moved off the surface of the prim.
    • The touch happened too close to the edge of the face to determine a location.
    • The event triggered is not a touch event.
All Issues ~ Search JIRA for related Bugs

Examples

default
{
    touch_start(integer total_number)
    {
        integer face = llDetectedTouchFace(0);
        vector  touchUV   = llDetectedTouchUV(0);

//      ZERO_VECTOR (<0.0, 0.0, 0.0> ... the origin) is in the bottom left corner of the texture
//      touchUV.x goes across the texture from left to right
//      touchUV.y goes up the texture from bottom to top

        if (face == TOUCH_INVALID_FACE)
            llWhisper(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
        else if (touchUV == TOUCH_INVALID_TEXCOORD)
            llWhisper(PUBLIC_CHANNEL, "Sorry, the touch position upon the texture could not be determined.");
        else
            llSay(PUBLIC_CHANNEL, "llDetectedTouchUV(" + (string)touchUV + ")"
                    + "\ntouchUV.x = " + (string)touchUV.x
                    + "\ntouchUV.y = " + (string)touchUV.y);
    }
}
integer numberOfRows    = 12;
integer numberOfColumns = 12;

default
{
    touch_start(integer num_detected)
    {
        vector touchUV = llDetectedTouchUV(0);

//      ZERO_VECTOR (<0.0, 0.0, 0.0> ... the origin) is in the bottom left corner of the texture
//      touchUV.x goes across the texture from left to right
//      touchUV.y goes up the texture from bottom to top

        integer columnIndex = (integer) (touchUV.x * numberOfColumns);
        integer rowIndex    = (integer) (touchUV.y * numberOfRows);
        integer cellIndex   = rowIndex * numberOfColumns + columnIndex;

        llSay(PUBLIC_CHANNEL, "UV grid (" + (string)columnIndex + ", " + (string)rowIndex + ") --> cell " + (string)cellIndex);
    }
}

See Also

Deep Notes

History

Search JIRA for related Issues

Footnotes

  1. ^ The ranges in this article are written in Interval Notation.

Signature

function vector llDetectedTouchUV( integer index );