Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

determining location of a "touch" ?

Maurice Mistwallow
Registered User
Join date: 9 Oct 2008
Posts: 23
01-23-2009 08:36
I was just curious if it is possible to determine where an object was "touched" when a person clicks it? I was thinking for example of a 8x8 checkerboard type thing where you would be able to click on the board and have the board respond based on which square you touched. The obvious solution is to have individual squares be prims but then you are talking about 64 prims vs 1 prim with a checkerboard texture and I was wondering if there was a way of doing this.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-23-2009 08:43
Use the llDetectedTouch functions. See the SL wiki at http://wiki.secondlife.com/wiki/LlDetectedTouchST.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-23-2009 08:45
lol, n/m someone beat me to it
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-23-2009 09:11
hmm, this example:

CODE

//Sets a grid of x by y, in this case 144 squares and returns that number on touch.

float x=12.0;
float y=12.0;
integer Pos;

default{

touch_start(integer total_number){
if (llDetectedTouchFace(0) == -1)
llOwnerSay("old client");
else{
vector pos = llDetectedTouchST(0);
Pos = ((llFloor((pos.x*10)*x)/10)*(integer)y)+llCeil(pos.y*y);
llOwnerSay((string)Pos);
}
}
}


seems to be reversed for how you would look at the x and y of a texture, i can't seem to figure out how to make it the same within the script without rotating the prim and/or texture
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Maurice Mistwallow
Registered User
Join date: 9 Oct 2008
Posts: 23
01-23-2009 10:32
ooh very good... i missed the llDetectedTouch stuff when I was looking... I really thought the answer was going to be that you can't do it. I'm glad I asked. Thanks!
Winter Seale
Registered User
Join date: 27 Dec 2006
Posts: 30
01-23-2009 12:39
In your defense, it is a pretty new feature. =)

Which does raise the point that you should be aware that it doesn't work for people using older viewers. It would be nice to know how many people still haven't upgraded...
_____________________
~~ Winter Seale ~~ http://winterseale.com/ ~~
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-23-2009 13:19
using the crosshair example from that page looks cool. i'm trying to apply that to llRezObject, can't seem to figure out the math i need to apply to make it rez the object at the touched point

nevermind, i needed llDetectedTouchPos, but i was trying to use llDetectedTouchST so that i could make the rezzed object centered on the square, llDetectedTouchPos rezzes exactly where you touch it
Abraxes Binder
Registered User
Join date: 23 May 2008
Posts: 205
01-24-2009 07:07
From: Winter Seale
In your defense, it is a pretty new feature. =)

..yes, and it STILL needs update in wiki
as do
http://www.lslwiki.net/lslwiki/wakka.php?wakka=functions:
llDetectedTouchBinormal (1.21)
llDetectedTouchFace (1.21)
llDetectedTouchNormal (1.21)
llDetectedTouchST (1.21)
llDetectedTouchUV (1.21)

-someone with wiki editing rights (and insight) is needed to udtate the wiki..!

BR
_____________________
BR ab
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-24-2009 08:02
From: Abraxes Binder
-someone with wiki editing rights (and insight) is needed to udtate the wiki..!

BR

It's a wiki, everyone has editing rights ;)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-25-2009 07:05
so from reading the SL Wiki on detectedtouchuv. it returns the uv of the texture? no matter how it's rotated or repeated, say i have a dot in the top right corner, anytime i touch it, it will always return the same uv?
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
01-25-2009 09:32
UV returns it relative to the Texture, ie repeats and such WILL affect the result. ST is relative to the Face of the prim. Pos is relative to the Region.
_____________________

Geometric Library, for all your 3D maths needs.
https://wiki.secondlife.com/wiki/Geometric

Creator of the Vertical Life Client
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-25-2009 13:16
If I recall from the brief testing I did of llDetectedTouchUV(), it returns values in the range (0,0)..(1,1) only for ONE of the repeats of the texture. However, it's a pretty simple matter to do a floating point style modulo operation to get the position on the texture for any other repeat. Something like:

CODE

vector normalizeUVCoords(vector uvCoords)
{
uvCoords.x = uvCoords.x-llFloor(uvCoords.x);
uvCoords.y = uvCoords.y-llFloor(uvCoords.y);
return uvCoords;
}