310 likes | 462 Views
DESC9180 Designing Virtual Worlds. Week 8 Interactivity I – Designing Dynamic Virtual Spaces 6pm – 9pm Tuesday, September 11 th , 2007 Kathryn Merrick and Owen Macindoe. DESC9180 Designing Virtual Worlds University of Sydney, September 2007.
E N D
DESC9180 Designing Virtual Worlds Week 8 Interactivity I – Designing Dynamic Virtual Spaces 6pm – 9pm Tuesday, September 11th, 2007 Kathryn Merrick and Owen Macindoe DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Lecture Overview • What is a dynamic virtual world? • Designing dynamic virtual worlds: • Tools • Techniques • Introduction to LSL Scripting Something Fishy Sim in Second Life DESC9180 Designing Virtual Worlds University of Sydney, September 2007
What is a Dynamic Virtual World? • Dynamic virtual worlds can change over time: • Simple dynamics: looping animations or scripted action sequences • Complex dynamics: elements can respond or adapt to user actions • Two key approaches: • Dynamic characters • Dynamic objects Dynamic objects: a rock that chases avatars DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Tools for Designing Dynamic Virtual Worlds • Function libraries • Scripting languages • Built into the virtual world • APIs for industrial strength programming languages • Open source clients LSL built into Second Life DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Function Libraries • A short list of triggers and commands that may be performed by an object: • Triggers: specify what must occur for a command to be carried out: • Eg: “bump” • Commands: an action to perform • Eg: “rotate” or “animate” • Several triggers and commands may be used together Active Worlds object properties window, including action field. DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Scripting Languages • Syntax for defining complex action sequences including: • Memory (variables) • Branches (if… then…) • Loops (for…) • More expressive than Function Libraries • Permit more complex world dynamics • Generally include a function library DESC9180 Designing Virtual Worlds University of Sydney, September 2007
APIs and Programming Languages • Application Programming Interfaces: • Gateways through which external computer software can communicate with a virtual world • Programming Languages: • Even more expressive than scripting languages • More memory, extended libraries… DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Using External Programming Languages • Second Life • Active Worlds XML-RPC AW Server SL Server External programming language C/C++ External programming language Java/C/C++/ Python etc LSL LSL XML-RPC DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Open Source Clients • Online virtual worlds use a client server architecture • Client software code may • Be publicly available or • Have official mod kits • Users make specialised client software • Statistics packages • Bug fixes Server Client Client DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Techniques for Designing Dynamic Virtual Worlds • Scripted commands • (Today’s lecture) • Artificial Intelligence (AI) • (Next week’s lecture) DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Editor and Compiler Script edit window New script Save and compile script Script location Error window Reset script Running toggle DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Introduction to the Linden Scripting Language (LSL) • Editor and compiler • States and events • Built-in functions • Variables • Flow control • Communication The Virtual Sentient, a dynamic virtual environment DESC9180 Designing Virtual Worlds University of Sydney, September 2007
State Machines • LSL is a state-machine based scripting language • State-machine based languages are common for designing dynamic virtual worlds Wait Deliver order Take order Simple state machine for a bartender… DESC9180 Designing Virtual Worlds University of Sydney, September 2007
States and Events: A Talking Table DESC9180 Designing Virtual Worlds University of Sydney, September 2007
States and Events (I) • Every script must have a default state with at least one event handler • This is where the script begins • You may then define other states as required… default { state_entry() { state happy; } } DESC9180 Designing Virtual Worlds University of Sydney, September 2007
States and Events (II) state happy { state_entry() { llWhisper(OPEN_CHANNEL, "I'm feeling happy."); } collision(integer num_detected) { llWhisper(OPEN_CHANNEL, "Ouch!"); state grumpy; } DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Built-in Functions:A Cheeky Chair • Use built-in functions to allow your scripts to monitor and modify the world • http://wiki.secondlife.com/wiki/LSL_Portal DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Built-in Functions DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Variables and Types • A variable represents a piece of memory • A variable has: • A type (green) • A meaningful name (black) • An assigned value (after = sign) vector current_pos = llGetPos(); DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Types • LSL has seven types: integer my_day = 28; float my_float = 4.9; vector my_pos = <1.6, 7.0, 5.4>; rotation my_rot = <1.6, 7.0, 5.4, 3.7>; string my_name = “Kathryn”; key my_key = “00000000-0000-0000-0000-000000000000”; list my_list = [23, “Test”, llGetPos(), my_name]; DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Flow Control: A Welcoming Mat • Flow control defines the order in which statements in your scripts are executed • Two important concepts are: • If statements • Loops DESC9180 Designing Virtual Worlds University of Sydney, September 2007
A Welcoming Mat DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Loops • Use loops to repeat one or more actions: integer i; for(i=0; i<num_detected; i++) { llWhisper(OPEN_CHANNEL, "Hello " + llDetectedName(i)); } DESC9180 Designing Virtual Worlds University of Sydney, September 2007
If Statements • Use an if statement to check a condition: stringname = llDetectedName(i)); if(name == “Sahi Kipling”) { llWhisper(OPEN_CHANNEL, “Welcome!"); } else if(name == “Illykai Pussycat”) { llWhisper(OPEN_CHANNEL, “Hello!"); } else { llShout(OPEN_CHANNEL, “Intruder alert!"); } DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Communication:Lights • Scripts can communicate with other scripts on hidden channels DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Lights DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Paper Review (I) • Review a research paper, magazine article or online publication about virtual worlds. • Presentations in class on 2/10/2007 starting at 6pm • To be done in pairs DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Paper Review (II) • Present the main ideas and conclusions of the article and your opinion of these. • Be prepared to discuss the article and your views with the class. • Each pair will have 10 minutes to make a slide show presentation and 5 minutes of audience questions and discussion. DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Paper Review (III) • Sources: • Conference proceedings • University research group websites • Popular websites • Other DESC9180 Designing Virtual Worlds University of Sydney, September 2007
Tutorial • Visit the Virtual Sentient in Furness (206, 9, 56) • Take a copy of some of the scripts you have seen in today’s lecture • Use the scripts as a starting point to build your own dynamic device DESC9180 Designing Virtual Worlds University of Sydney, September 2007
For Next Week • Reading: • Maher, M-L., Merrick, K.: (2005) Agent Models for Dynamic 3D Virtual Worlds, Proceedings of the 2005 International Conference on Cyberworlds, Singapore, pp 27-34. • http://www.cs.usyd.edu.au/~kkas0686/publications/cw2005v06.pdf DESC9180 Designing Virtual Worlds University of Sydney, September 2007