SL TrackingLast changed: 2009/02/07 23:21 |
||
---|---|---|
Main page / Recent changes go back | refresh | help | Pages Index | create a page | upload | What links here? | locusonus.org | Show source / History | |
Menu : Second Life
Scott Fitzgerald A birds-eye view of the process required to get the position of an object from Second Life into a Pure Data patch is fairly straightforward. There are some “gotchas” outlined below. These primarily lie in the Second Life domain. Second Life has its own scripting language, with the uninspired name of Linden Scripting Language (LSL). The scripts can be attached to any in-world object you have appropriate permissions for, including your body. LSL allows for http requests to be made from inside the world to connect to external content (web pages, audio, video). By making a request to a webserver running PHP, we can send the x,y,z coordinates of the object we are interested in. In this instance we are also sending the object’s rotation along the z-axis in radians. When the request is made, the PHP parses the information, and opens a UDP socket on the local machine. We have a Pure Data patch listening on the socket for incoming information. The information is routed according to the object’s name, giving us the position of each object inside the virtual space. There were several different iterations of the LSL script, for various reasons. LSL throttles http requests, limiting them to about 1 second per object. If you have a request attached to a large object (about the size of an average avatar), the object loses “energy” over time, it cannot continue to make requests until that “energy” has replenished (achieved by not making requests). Another issue we encountered is that the objects will report bogus location data, intermittently reporting their location was somewhere different than where they currently were. This happened irregularly, and usually appeared after about an hour of “rezzing” an object with the script. The original script we were using only reported an object’s beginning and end position. No updates between were registered. This proved problematic, as objects could move from one side of the space to the other, sounding as if it happened instantaneously. The second iteration had the objects constantly updating their location, whether they were being moved or not. This became problematic for the reason mentioned above, they would erroneously report their location, stating they were somewhere else (often time this appeared to be a previous location). A compromise was reached, whereby the object would report its location every second while it was being touched. Random location data would still sneak in while a participant would be moving something. However, it was much less frequent and would not cause problems once the object was positioned. One unfortunate side effect of this is that if an object’s position was changed through collision with another object or avatar, or if momentum carried it away from the place it was last touched, its location would no longer be accurate. One other bit that needed to be added to the LSL was a boundary checker. We did not want the object to leave the confines of the Locus Sonus parcel of land. However, there was ample opportunity for people to move the objects out of our space. This was alleviated through a small script that constantly checked if the object was within our land’s coordinates. If it was not, it would be turned “phantom” (to allow the object to pass through walls), moved to the silent zone. Once reaching the resting place, it would be returned to its normal “physical” state.
the setup : 1) know your external IP address (whatismyip.com can tell you this). 2) in all instances of the second life tracking script, change the ip address to your current one (line 4) 3) have your computer's webserver turned on & php enabled Under OSX, to turn on apache with the gui : System Preferences ->Sharing->check "Web Sharing" PHP might be on by default, but if not, you'll need to edit httpd.conf (found at /etc/httpd/httpd.conf) and uncomment the following lines :
and
(just delete the # and save, restart apache) 4) place the php file below at the root of the server (on osx it is found in /Library/Webserver/Documents/") name the file "put_data.php" 5) make sure all web traffic is routed to your computer (anything on port 80 really). the way to do this is determined by the network setup. if you have an ip that is exposed to the world, you may not have to change anything, if you are behind a firewall/router you will need to "forward" port 80 to the machine that is acting as the webserver. 6) open the PD patch "MainSL.pd" in found in this directory : http://nujus.net/~locusonus/dropbox/patchs/LSSL_2.zip 7) you will need to change the path to the sound file for the weather bit 8) turn on the sound, and click the inits in the holoboule patch. 9) if you are unsure there is information getting to the patch from the script, or SL, check the print box in the main patch. whenever an object is moved, you will see its coordinates printed in the window. The LSL bit
2) php script {<?php /* Script for getting object type, name and data via http and sending to a udp socket -Scott Fitzgerald apr 08 based on - Robb Drinkwater, Aug. '07, Jan. '08
$type = $_REQUEST'type'; // get object type $obj_name = $_REQUEST'name'; // get object name $pd_data = $_REQUEST'data'; // get object data echo "<h2>UDP Connection</h2>\n"; /* Get the90.4.219.15address for the target host. */ $address = gethostbyname('localhost'); /* Create a UDP/IP socket. */ $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; else { echo "OK.\n"; }//open a port echo "Attempting to connect to '$address' on port '13001'..."; $result = socket_connect($socket, $address, 13001); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "OK.\n"; }/* Catch if data is Second Life vector format and reformat */ if(strstr($pd_data, '<') == true) {//print "found vector format"; $as_list = str_replace(array("<",">"), "", $pd_data); // strip lt/gt $as_list = str_replace(",", " ", $as_list); // replace commas $pd_data = $as_list; }$formatted = $type." ".$obj_name." ".$pd_data."\n"; // Formatted as raw 'type','name','data' list //if the "formated" string length is greater than 1 (i.e. we assume it gets data) //open socket connection and send data if (strlen($formatted) > 1) {socket_send($socket, $formatted, strlen($formatted), MSG_DONTROUTE); } ?> }} 3)pd patch
|
||
Powered by LionWiki 2.2
2024/12/27 01:03 -- 18.220.196.68 Erase cookies |
Show source / History |