Talk:LlDetectedTouchUV

From Second Life Wiki
Revision as of 17:08, 6 August 2012 by Windy Schor (talk | contribs) (Created page with "If someone would please look at the following with an editor's eye, I'd like to add this clarification to the page. Should there also be an example of how offsets can make the re…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

If someone would please look at the following with an editor's eye, I'd like to add this clarification to the page. Should there also be an example of how offsets can make the results be offset?

llDetectedTouchUV returns the U,V corresponding to the part of the texture touched, plus any U and V index of tiled repeats. For example, if you set two repeats vertically and one horizontally, with no texture-offset and no texture-rotation, clicking in the middle of the upper half yields <1.5,0.5,0.0> and clicking in the exactly same spot on the lower copy of the texture, i.e. the middle of the bottom half, yields <0.5,0.5,0.0>. Thanks to this feature, one can determine not only where on a texture the touch was detected, but on which repeat of the texture, in case that matters.

The position touched on the texture, ignoring repeats and/or determining which repeat, is determined thusly: <lsl> vector DTUV=llDetectedTouchUV(index); vector position_on_texture = <DTUV.x - (float)llFloor(DTUV.x), DTUV.y - (float)llFloor(DTUV.y), 0.0>; list which_repeat = [ llFloor(DTUV.x), llFloor(DTUV.y) ]; </lsl> Windy Schor 18:08, 6 August 2012 (PDT)