Vrml To Second Life Translator

The typical SecondLife hello world script is

default {

    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

touch_start(integer total_number) { llSay(0, "Touched."); }
}

Partial vrml ( VirtualRealityModelingLanguage ) scripting translation of the program above follows for comparison. Trying to write mappings from vrml (Javascript) scripting for SLScript functions as I find it's faster to test what the 3D looks like in vrml (no lag, which I find makes programming in SL challenging). Since the plug-ins are freely available for any browser. With the view to then login and paste to the code editor in SL and make minor modifications to syntax, which is also similar. Would be interested to know if there are already (free) off-line SLScript editors or existing vrml mappings. Anyway here is a version of touch_start() above. The same could be done for state_entry(). It seems verbose but once all the functions were defined, I think you could make programs that would be very close to how they would look in SL. This would accelerate scripters ability to develop. The code below should work by just typing in notepad as hello.wrl and double clicking assuming a vrml plug-in is installed in IE, Firefox etc.

#VRML V2.0 utf8 #hello.wrl

DEF add_box Script {

  field SFBool pointer_over FALSE
  field SFVec3f position 1 0 0 
  eventIn SFBool isClicked
  eventIn SFBool isOver
  eventOut MFNode new_child

url "javascript:

function touch_start(total_number) { llSay(0,\"touched\"); }

function llSay(ch,t) { obj_string = Text(t);

node = Browser.createVrmlFromString(obj_string); node.setTranslation = position; new_child = node; position[0] += 1; }

function Text(t) { i = 1;j=1; b = \" Transform {\"; b += \"translation \"+i+\" \"+j+\" 1\"; b += \"children [\"; b +=\" Shape {\"; b += \" geometry Text {string [\\\" \"+t+\" \\\"] fontStyle FontStyle? {size .5}} }\"; b +=\"] }\"; return b; } function isClicked(button_pos) { if(button_pos == 0) { if(pointer_over == 1) { touch_start(0); } } } function isOver(value) { if(value==0) pointer_over = 0; else pointer_over = 1; } "
} Transform {
  translation 3 0.5 4.5
  children [
Shape {appearance Appearance { material Material { emissiveColor .5 .4 .5 } } geometry Box {size 1 1 1}
  }
  DEF box_touch TouchSensor? {}
  ]
}

DEF box_stack Transform {

  translation 0 0 -4.5
}

ROUTE box_touch.isActive TO add_box.isClicked ROUTE box_touch.isOver TO add_box.isOver ROUTE add_box.new_child TO box_stack.addChildren


EditText of this page (last edited April 26, 2006) or FindPage with title or text search