LlDetectedTouchUV

来自人工智能助力教育知识百科
Qmf讨论 | 贡献2020年4月13日 (一) 10:36的版本 (创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: vector llDetectedTouchUV( integer index ); |参数= 参数…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: vector llDetectedTouchUV( integer index );
参数:integer index–Index of detection information index does not support negative indexes.
返回值: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.
注意事项
注意事项
  • 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.
      • 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 touch event.
示例
示例1
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);
    }
}

示例2

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);
    }
}
相关函数
llDetectedLinkNumber

llDetectedTouchFace llDetectedTouchST llDetectedTouchPos llDetectedTouchNormal llDetectedTouchBinormal

相关事件
touch_start

touch touch_end