Marianne McCann Posted June 10, 2012 Share Posted June 10, 2012 Hiya!So I'm not sure if what I'd like to do will work - but maybe all y'all will have an inkling.I would like to apply a texture like this to a prim:http://www.flickr.com/photos/marianne-mccann/7168503497/Then use llDetectedTouchUV to, essentially, make the map clickable for more information. For example, if someone clicks within the coorcinates surrounding, oh, the Bay City Fairgrounds, it will give text to the user about that location. Ditto other spots on the map.I've done somethign similar in the past, using llDetectedTouchFace, but this seems more prim conscious.So... is something like that possible? Are there any good example scripts or pointers anyone can give me to lead me in the right direction?Thanks in advance! Link to comment Share on other sites More sharing options...
Tori Oodles Posted June 10, 2012 Share Posted June 10, 2012 If you don't get an answr, maybe you can afford the prims to try this approach. Divide your map texture into portions you can piece together to appear a one. Make each section is touchable to give a notecard to the user. With multiple points in any one section, ask the user which one he wants, then listen for the answer. If the answer is not recognized, give them a single note with all destinations in the section - ( :smileywink: or just eject them after a GONG sound, and an AM radio announcer saying "Sorry! You Loooose!") Link to comment Share on other sites More sharing options...
Hugsy Penguin Posted June 10, 2012 Share Posted June 10, 2012 I wrote the attached script assuming you wanted to check for clicks based on pixel coordinates in the original image. (rez box, add your image, add this script, click). If you have questions or needed something different, let me know. integer IMAGE_WIDTH = 2048; //pixel width of original image applied to prim face integer IMAGE_HEIGHT = 1057; //pixel height of original image applied to prim face // // Determine if coordinate is within the given bounding rectangle. // // input: uv - vector returned from llDetectedTouchUV // - (0, 0) is bottom left // - range is 0.0 to 1.0 // input: minx - leftmost pixel coord of rectangle (0 = leftmost) // - range is 0 to IMAGE_WIDTH // - must be less than maxx // input: miny - uppermost pixel coord of rectangle (0 = uppermost) // - range is 0 to IMAGE_HEIGHT // - must be less than maxy // input: maxx - rightmost pixel coord of rectangle (0 = leftmost) // - range is 0 to IMAGE_WIDTH // - must be greater than minx // input: maxy - lowermost pixel coord of rectangle (0 = uppermost) // - range is 0 to IMAGE_HEIGHT // - must be greater than miny // // output: TRUE if UV within (uplef, lowrt), FALSE otherwise // integer CheckRect(vector uv, integer minx, integer miny, integer maxx, integer maxy) { integer checkX = (integer)(uv.x * IMAGE_WIDTH); integer checkY = (integer)((1.0 - uv.y) * IMAGE_HEIGHT); if ((checkX >= minx) && (checkX <= maxx) && (checkY >= miny) && (checkY <= maxy)) { return TRUE; } return FALSE; } // // Determine if coordinate is within the given bounding circle. // // input: uv - vector returned from llDetectedTouchUV // - (0, 0) is bottom left // - range is 0.0 to 1.0 // input: centerx - pixel coord of center of circle (0 = leftmost) // - range is 0 to IMAGE_WIDTH // input: centery - pixel coord of center of circle (0 = uppermost) // - range is 0 to IMAGE_HEIGHT // input: radius - distance from the center (in pixels) to check // // output: TRUE if UV within (uplef, lowrt), FALSE otherwise // integer CheckCircle(vector uv, integer centerx, integer centery, integer radius) { integer checkX = (integer)(uv.x * IMAGE_WIDTH); integer checkY = (integer)((1.0 - uv.y) * IMAGE_HEIGHT); integer dist = (integer)llSqrt(((checkX - centerx) * (checkX - centerx)) + ((checkY - centery) * (checkY - centery))); if (dist <= radius) { return TRUE; } return FALSE; } default { touch_end(integer total_number) { vector UV = llDetectedTouchUV(0); // check to see if Wellfleet Harbor was clicked // upperleft = (528, 361) // lowerright = (694, 529) if (CheckRect(UV, 528, 361, 694, 529) == TRUE) { llWhisper(0, "You clicked Wellfleet Harbor."); } //check to see if Bay City Fairgrounds was clicked //center = (1944, 590) //radius = 50 pixels else if (CheckCircle(UV, 1944, 590, 50) == TRUE) { llWhisper(0, "You clicked Bay City Fairgrounds." ); } else { llWhisper(0, "Nothing of interest here."); } } } Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted June 10, 2012 Share Posted June 10, 2012 I'm not sure what your questions relating to this function are. For you're task, you may use llDetectedTouchST - but even if you don't the examples there are good to understand how either of the functions work. The only thing you have to remember: <the coordinates are relativ to the size and between 0 and 1. Here is a very simple example: default { touch_end(integer num_detected) { if(llDetectedTouchFace(0) == 1) { //I only want touches on face 1 vector vec = llDetectedTouchST(0); if (vec.x > 0 && vec.x < 0.1) { //was the touch on the left tenth of the face if(vec.y > 0 && vec.y < 0.1) { //was the touch in the lower tenth of face 1 llSay(0, "Touched in the lower left corner."); } } } }} Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now