One neat feature of the web is the ability to create image maps. We take for granted that you can often interact with images and get different responses depending on where you click. But until very recently this has not been possible in Second Life.
However now it is, thanks to a new function called llDetectedTouchST. This function allows you to return coordinates you have touched on the face of a prim. If you have a rectangular face the upper left corner is 0,0 and the lower right corner is 1,1.
I have found that with successive calls to this function, you can design rectangular hot spots for a texture. The texture can be anything from an image of a leaf, to menu items or a city map that you want a visitor to interact with. For learning purposes, I decided to set up an interactive leaf using this function. The object tells the visitor what the part is and displays a short text explanation as a texture of an object rezzed when the visitor touches on the appropriate spot on the leaf. I thought about displaying the textures as particles but decided that rezzing objects would give me greater flexibility.
I built in an interesting feature and this came about because I haven't quite mastered how SL handles coordinates. When I rotated the leaf prim, the objects with the explanations often ended up behind or on the wrong side of the leaf. Rather than mess with figuring out the right set of coordinate functions. I decided on a different strategy. I made an invisible prim called "positioner" linked to the leaf object and let it determine where the explanations are rezzed.
This is cool because it allows me to customize where the explanations rezz without with any sort of code. I just move the positioner prim to the right position. To make this little feature I linked the leaf prim to the positioner prim and then used the following set of statements in the Leaf's code to rezz the objects:
puthere = llGetObjectDetails(llGetLinkKey(2),[OBJECT_POS]);
llRezObject(part_name, llList2Vector(puthere,0), <0,0,0>, llGetRot(), 0);
The variable "puthere" is a list and the position of puthere has to be extracted from the list by llList2Vector.
The image shows the invisible prim highlighted (translucent red cube) in the middle of the object for Phloem.
Right now the hot spots and object names for rezzing are written into the code, but it should be easy to have all this be somewhat more automated were I to make this tool generally available. Unfortunately you need to find the prim coordinates for the hot spots by hand via repeated calls to llDetectedTouchST.
If you want to play with the leaf, and assuming SL is installed on your machine, just teleport to my home in Carmine at:
Malcolm’s Wee Specimens
8 months ago