secondlife

You are currently browsing articles tagged secondlife.

In OpenSim you’re not just restricted to using LSL for scripting, it’s also possible to use c#. This opens up the possiblilities for far more powerful scripts that can access c# in built libraries.

For example I’ve previously mentioned that the string processing methods in Second Life are not very flexible when it comes to reading formatted data. Thus the reason I implemented the osParseJSON method to make Web APIs easier to use.

Obviously another common data format is XML, in this case I don’t have to implement any new OpenSim script functions because the XML capabilities are available natively in c#.

Here is a simple example of reading the RSS feed for my blog, and reading out the entries in chat.


//c#
// displays the contents of an RSS 2.0 feed

string URL = “http://robsmart.co.uk/feed”;
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
LSL_Types.LSLString requestID;

public void default_event_state_entry()
{
    llSay(0,”RSS reader current Feed is ” + URL);
    getFeedContent();

}

public void getFeedContent()
{
    requestID = llHTTPRequest(URL, new LSL_Types.list(), “” );
}

public void default_event_touch_start(LSL_Types.LSLInteger total_number)
{
    // read out the RSS feed.
    displayFeed();

}

public void displayFeed()
{
    System.Xml.XmlNodeList items = xDoc.GetElementsByTagName(”item”);

    for(int i=0;i
    {
        string title = items[i].SelectSingleNode(”title”).InnerXml;
        string link = items[i].SelectSingleNode(”link”).InnerXml;

        string description=”no description available”;

        if(items[i].SelectSingleNode(”description”)!=null)
            description = items[i].SelectSingleNode(”description”).InnerXml;

    llSay(0,title + “\n” + description + “\n”);
    }
}

public void default_event_http_response(LSL_Types.LSLString request_id, LSL_Types.LSLInteger status, LSL_Types.list metadata, LSL_Types.LSLString body)
{
    if (requestID == request_id)
    {
        // store the xml
        xDoc.LoadXml(body);

        // process the xml
        llOwnerSay(”loaded feed”);
    }
}

OpenSim Web 2.0 contribution

As described over on Eightbar I have made my first contribution to the OpenSim opensource project. The contribution is in the form of a new scripting function called osParseJSON. This function allows a c# script in OpenSim to consume the JSON notation provided by many of the major Web 2.0 APIs provided by services such as Flickr and Google translation.

The following example is a script that uses the Google Translate API to let an OpenSim avatar translate ther conversations between 23 different languages.

(disclaimer - please read the terms of conditions of the Google translate API and abide by them)

//c#
// This script is written as an example use of the osParseJSON method
// it uses the Google translate API
// ensure you have read the terms and conditions of the Google translate API
// http://code.google.com/apis/ajaxlanguage/documentation/

LSL_Types.key requestID;
string sourceLang = "en";
string targetLang = "fr";

public void default_event_state_entry()
{
     llSay(0,"translator running say '/1 sentence' to translate something");
     llSay(0,"translator running say '/2 source langage' to change target language e.g. '/2 fr'");
     llSay(0,"translator running say '/3 target langage' to change source language e.g. '/3 en'");
     llSay(0,"translator running say '/4 help', to list languages");
     llListen(1, "", NULL_KEY, "");
     llListen(2, "", NULL_KEY, "");
     llListen(3, "", NULL_KEY, "");
     llListen(4, "", NULL_KEY, "");
}

public void default_event_touch_start(LSL_Types.LSLInteger total_number)
{
     llSay(0,"translator running say '/1 sentence' to translate something");
     llSay(0,"translator running say '/2 source langage' to change target language e.g. '/2 fr'");
     llSay(0,"translator running say '/3 target langage' to change source language e.g. '/3 en'");
     llSay(0,"translator running say '/4 help', to list languages");
}

public void default_event_http_response(LSL_Types.LSLString request_id, LSL_Types.LSLInteger status, LSL_Types.list metadata, LSL_Types.LSLString body)
{
        if (requestID == request_id)
        {
            // the Google JSON string returned wil be of the format
            //  {"responseData": {"translatedText":"Bonjour"}, "responseDetails": null, "responseStatus": 200}
            // call the osParseJSON method so we can read the contents 
            System.Collections.Hashtable response = (System.Collections.Hashtable) osParseJSON(body);
            System.Collections.Hashtable responsedata = (System.Collections.Hashtable) response["responseData"];

            llSay(0,(string)responsedata["translatedText"]);
        }
}

public void default_event_listen(LSL_Types.LSLInteger channelIn, LSL_Types.LSLString name, LSL_Types.LSLString id, LSL_Types.LSLString message)
{
    if(channelIn==1)
    {
        string toTranslate = (string) message;
        requestID = llHTTPRequest( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="+toTranslate+"&langpair="+sourceLang+"%7C"+targetLang, new LSL_Types.list(), "" );  

    }
    else if(channelIn==2)
    {
        sourceLang = (string) message;
    }
    else if(channelIn==3)
    {
        targetLang = (string)message;
    }
    else if(channelIn==4)
    {
        llOwnerSay("LANGUAGE (CODE)");
        llOwnerSay("*  Arabic (ar)");
        llOwnerSay("* Bulgarian (bg)");
        llOwnerSay("* Chinese (zh)");
        llOwnerSay("* Croatian (hr)");
        llOwnerSay("* Czech (cs)");
        llOwnerSay("* Danish (da)");
        llOwnerSay("* Dutch (nl)");
        llOwnerSay("* English (en)");
        llOwnerSay("* Finnish (fi)");
        llOwnerSay("* French (fr)");
        llOwnerSay("* German (de)");
        llOwnerSay("* Greek (el)");
        llOwnerSay("* Hindi (hi)");
        llOwnerSay("* Italian (it)");
        llOwnerSay("* Japanese (ja)");
        llOwnerSay("* Korean (ko)");
        llOwnerSay("* Norwegian(no) ");
        llOwnerSay("* Polish (pl)");
        llOwnerSay("* Portuguese (pt-PT)");
        llOwnerSay("* Romanian (ro)");
        llOwnerSay("* Russian (ru)");
        llOwnerSay("* Spanish (es)");
        llOwnerSay("* Swedish (sv)"); 

    }
}

Second Life hidden video secrets

There is a very little known feature of Second Life to do with showing video in world, this is the ability to show different videos to individual avatars on the same land parcel. I’ve mentioned this to a quite a few people now and all have been in disbelief, even some of the Lindens seem to be unaware of this feature.

The method to do this however is not a hack and has in fact been documented in the LSL API for as long as I know.

The method in question can be discovered by looking at the documentation for llParcelMediaCommandList if you have a close look at the parameters there is one called

PARCEL_MEDIA_COMMAND_AGENT

the description for which is “Applies the media command to the specified agent only.”

So lets look at a quick simple example.

We need a screen that can listen for urls over chat and then set the url for the person speaking. ( The screen must be owned by someone who has media permission on the land )

The script for the screen is …

integer listen_handle;

default
{
state_entry()
{
listen_handle = llListen(10, “”, “”, “”);
}

touch_start(integer total_number)
{
llSay(0, “talk on channel 10 to set your personal video for this land”);
}

listen( integer channel, string name, key id, string message )
{
llSay(0, “Setting Video play back to ” + message);
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_URL, message,
PARCEL_MEDIA_COMMAND_AGENT, id,
PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] );
}

}

Here’s a quick side by side screenshot of two AVs watching a different movie at the same time on the same parcel of land.

secondlife yoss videozeki video

Extra points for guessing what movie trailers they are watching :P

11 Second Life Machinima tips

If you’re aiming for a more professionally produced machinima piece then the following tips are for you, in no particular order…

Hardware
Use a beefy desktop if possible. You need a decent graphics card and plenty of RAM. A fast hard disk really helps capture smooth video, slow disks and low RAM will cause you headaches as your buffers will fill up before the video can get writen to disk.

Record in as high quality as your machine can manage
If you’re filming on a decent desktop machine and it can cope then go for 1024p resolution, this will give you the best quality playback if you’re projecting onto a large cinema screen or using a High Definition plasma/LCD display. Go for 720p as the next best option (this is what i use most of the time)

Playback at an Event (trade show/conference)
Always playback from a computer hooked up to the monitor/projector. dont be tempted to put the machinima on tape or DVD the resolution is much worse than you’d think. If doing a live broadcast event using the video have a machine for backup, as last resort use a tape or DVD backup.

Hiding the UI
Unless you’re doing documentary or event capture where you need avatars chat text you’ll want to hide the UI, do this using CTRL-ALT-1

Avatar chat
If you’re filming a scripted piece then put the captions on afterwards, the standard SL chat is small and hard to read when playing back at a lower resolution save your viewers eye strain and add the captions afterwards along with any other titling. This also gives you the option to quickly do changes when your client comes back to you and requests a script change (which they will).

Things to tell your client
Make sure they know that filming machinima is a vary similar process to RL filming, you’ll need props, actors and a script. You’ll have to do multiple takes and post editing. It all takes time. If you are able to have influence on the script etc try and keep the number of characters in each scene to a minimum.

Actors
As mentioned before, if you can keep actor numbers low do so, if you’re lucky enough to have access to multiple machines use alts and control the characters yourself when numbers permit. I use three machines on occasion which lets me use 3 avatars with one being the camera.
If you do end up using a lot of other avatars try and get them to all go on a conference call. its much easier directing by voice rather than typing when you’re trying to use you avatar as a camera.

SecondLife tools
Filming Path HUD is essential for getting smooth camera shots - panning, top shots etc. it’s the best tool around and allows you to lay out the path you want your camera to follow. You can set a focus target on another avatar to smoothly follow them while they and the camera moves. You can also set static focus points so that you your camera will stay fixed looking at a set point even when moving through complex curved paths etc.

Be creative with angles (but don’t over do it ;)
Filming machinima allows you the freedom to use creative angles more easily than RL filming. try shots from above, below, panning, swooping and aerial. make sure they will fit together nicely when you edit afterwards though i.e. keep continuity in mind.

Don’t forget composition
If you’re new to filming or photography then look up some of the composition rules of thumb, leading lines, rule of thirds etc.. once you know these simple guides you’ll spot them turning up again and again in hollywood films. They’re not hard fast rules but they work as a starting point and will help make your machinima a more visually pleasing experience for the viewer.

Film more than you need
play with different angles and capture scenes more than once. You can edit afterwards and pick the best pieces to use, if you have a script change then some of the excess video you’ve captured might come in useful.

Hope some of these come in handy in some way, if you have any more tips then please add them in the comments :)

Well I haven’t done any machinima posts of late, but I can feel a few in the offing having just completed one concept video for a client and with the promise of a few more lurking not too far in the distant future.

The machinima I’ve been doing has generally been of the type you use when you can’t do a live demonstration of SecondLife, it’s been produced to either illustrate potential scenarios/concepts or show case existing business aspects of secondlife. The venue for displaying this machinima has been at trade shows or during large presentations.

Video and particularly Machinima seems to keep cropping up in my day to day job at the moment, a client I’m currently working for has a need for a streamed video service for use at events. We want something reliable but cheap that we can use for the occasional streaming of a live event etc. into Second Life (any suggestions welcome :)

The one service I have been playing with at the moment is a startup called Veodia (veodia.com) which is currently in beta. It’s very similar to another beta startup
called ustream (ustream.tv) the one distinct and important difference (with my SL oriented slant) is that it makes available the video stream in quicktime format. Meaning that it can be streamed straight into Second Life with no conversion faffing or trouble finding dedicated servers to run a Darwin streaming server on.

Ian pointed me at Veodia a few weeks ago, however it took my account registration email some time to materialise (it was trapped in Hotmails spam catcher) so I was a bit slow off the mark in checking out what format the streaming was done in. Kevin Aires as ever the video streaming investigator got in there and found it was quicktime compatible and blogged within IBM about getting a Veodia stream into SL.

After finally getting into my account yesterday I started up my softcam desktop streaming app, set up a quick feed on veodia, grabbed the rtsp link from a view source and set the media url for my land parcel in Ukanipo.

Here’s the result a slightly disturbing world within world effect…

.

So what you are seeing here is the result of softcam capturing my desktop video display output, streaming it up to veodia and then it being streamed into SecondLife. Infinite loop complete. (ps the quality is better when you don’t go for this wheels within wheels effect)

So whats this useful for ?

-video conferencing: pipe your webcam into SL without the need to host your own streaming server.
- live demos: do desktop sharing to a crowd in SL so you can do demonstrations from other apps (shared browsing or 3d app tutorials anyone?), simutaneously visible on the web stream too.
- world tours: get all your guests into one place with a screen in SL and then disapear off streaming your secondlife journey back to the assembled SL crowd.
- video link parts of SL: running a live event over several islands ? then provide video linkups between each of the islands so everyone can see what’s going on.

best of all veodia which is in beta is currently free, oh and it records too ;)

ooo check out the pretty sunsets coming our way soon in Second Life…

The interesting part is that Linden purchased Windmark, they must be feeling a bit more comfortable of late financially which is a good thing. I have to say purchasing existing technologies to improve SL is a good tactic, the existing Linden developers would be hard pressed to put in the time required to develop these features from scratch.

The ever inventive and productive Dave CJ from our emerging tech department at work has been hooking up more of his demonstration lab to SecondLife. Tracking the state of everyday objects and visualizing their state in world allows for remote control of devices and a quick way to check up status of a remote site/home or factory type installation. There’s a nice detailed write up over on UgoTrade..