Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDetectedTouch UV/ST and Sculpties

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
04-24-2009 09:27
i saw someone talking about this on a thread a while back just after these functions were introduced. lslwiki.net doesn't seem to have been updated for these functions at all, the official lsl wiki is very vague. anyways. my problem is. i have a sculpty that's 1 prim but 3 drawers. what i want to do is change the sculpt map (and size of the prim) depending on which drawer was clicked. i was thinking i could use st or uv to make it work, but i don't understand these functions

edit: yes i know i could just go to seperate drawers and make it easier, but i wanted to use as few prims as possible
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
04-24-2009 10:56
ok, i thought i figured out what i needed to do to determine which drawer i touched. but it always returns drawer 1 with this script, can anyone spot my error?

CODE

integer drawer;
default {

touch_start(integer num_detected)
{
vector tpos = llDetectedTouchST(0);
if(tpos.y < 50.0){drawer = 1;}
else if(tpos.y > 50.0 && tpos.y < 70.0){drawer = 2;}
else{drawer = 3;}
llOwnerSay((string)tpos);
llOwnerSay("You touched drawer " + (string)drawer);
}
}
_____________________
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
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
04-24-2009 11:08
Silly question, but are you sure that you're clicking on the Y-Z face, not the X-Z face? You can check to be sure by using llDetectedTouchFace.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
04-24-2009 11:14
it's a 1 prim sculpty, only 1 face. i put in a standard cube and it still returns drawer 1 but it's flipped 180 degrees. notice i put the debug owner say so i can see the vector it returns as well. tpos.y is obviously more than 50 when i'm clicking drawers 2 and 3, but it still says drawer 1
_____________________
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
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
04-24-2009 11:26
Ah.... well, the scale on those variables is 0.0 to 1.0. You have them scaled as 0.0 to 100.0. Here's how I'd do it with llDetectedTouchUV .....

CODE

vector UV = llDetectedTouchUV(0);
if (UV.y<= 0.5 )
{// etc.}


It ought to work the same way with llDetectedTouchST.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-24-2009 13:05
you might want to preload those sculpts in a hidden prim (basically hide it inside the dresser) so that it doesn't turn into a blob in between


although at that point you've only saved 1 prim over a simple 4 prim dress with 3 drawers (although it'll look nicer)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
04-24-2009 21:20
From: Void Singer
you might want to preload those sculpts in a hidden prim (basically hide it inside the dresser) so that it doesn't turn into a blob in between


although at that point you've only saved 1 prim over a simple 4 prim dress with 3 drawers (although it'll look nicer)


yeah, i already got to that part with a cut and hollowed cube that's textured with the sculpt maps. i just need to figure out how to let the script know which drawer was clicked. then from there, i need to figure out how to know which drawer or drawers are open to know which map to use, IE;

drawers 1 is open, 2 and 3 are closed. click drawer 3, it will then load the map the has 1 and 3 open and 2 closed. click drawer 1, switch the map with only 3 open. click 2, switch to the map with 2 and 3 open. click 2 again, switch back, click 3 again, load the one with all closed. of course i could use the same map for when they're all open/closed, and i would need to determine if it needs to be rescaled/moved depending one which ones are open. the all open/closed state is about half the size on one axis (in this case the Y axis) than it is when 1 or 2 are open). i know i can do it with integers, just need to figure out the logic, but need to know which one was clicked before i can get there. and when testing for vectors, the ST was about the same (on the y axis). the bottom of drawer 1 ends more are less at 0.4 drawer 2 starts at more or less 52, so well enough of a space if that changes a little when the scale changes
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
04-24-2009 22:16
From: Rolig Loon
Ah.... well, the scale on those variables is 0.0 to 1.0. You have them scaled as 0.0 to 100.0. Here's how I'd do it with llDetectedTouchUV .....

CODE

vector UV = llDetectedTouchUV(0);
if (UV.y<= 0.5 )
{// etc.}


It ought to work the same way with llDetectedTouchST.

ack, you're right, it took me a little while to catch that
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-25-2009 07:35
I'm not quite sure about all the different bounding box shapes availabe of sculpts, but I imagine that the angle viewed from might skew results too (not sure but I believe the touch would be registered at the unsculpted surface) something to check on anyways
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Monster Behemoth
Registered User
Join date: 22 Dec 2004
Posts: 6
04-25-2009 12:05
I just did some quick testing and I confirmed my suspicions: the llDetectedTouchUV reports where you touch the actual texture(it doesn't change based on geometry). So I would just load a grid type texture and figure out where the texture is mapped to the drawers. To know which texture to load, you could possibly do a bitfield or something. Just have a value of 000 for no drawers open or 111 for all drawers and flip whatever bit needs flipping to change the drawers. Then store all the texture UUIDs in a list after the bit combinations and search after each touch event. This might not be the best way, though. I hope this helps.