Template:Needs Translation/
函数名
|
Function: vector llDetectedTouchUV( integer index );
|
参数:整数索引—检测信息索引不支持负索引。
|
返回值:返回一个矢量,该矢量是prim被触摸的地方的纹理坐标。x和y矢量位置分别包含水平(u)和垂直(v)纹理坐标(<u, v, 0.0>)。与llDetectedTouchST类似,除非纹理重复被设置为非默认值,否则每个组件的间隔将为[0.0,1.0]。增加或减少面部重复的纹理将相应地改变这个间隔。此外,与llDetectedTouchST不同的是,改变纹理的旋转会改变这个函数的结果。
|
注意事项
|
注意事项
- 如果索引超出界限,脚本将继续执行,不会出现错误消息。
- TOUCH_INVALID_TEXCOORD在…
- 头像查看器不支持面部触摸检测。
- 检查是否支持face touch检测,检查llDetectedTouchFace返回。
- 触摸已经离开了表面的prim。
- 触摸太靠近脸的边缘,无法确定位置。
- 触发的事件不是触摸事件。
|
示例
|
示例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);
}
}
|