Difference between revisions of "Guides/Architecture"
(Initial import from sirikata-docs)
Revision as of 19:05, 25 May 2012
This document describes the basic components of a Sirikata world at the highest (and hopefully non-technical) level. Whether you're developing an application in a Sirikata world or creating and deploying your own world, you'll need to understand these basic components. World developers need to understand these components because they will configure and run them to pull together a virtual world. Application developers need to understand them because they interact with each component.
At the highest level, Sirikata is composed of three parts: the space, the object hosts, and the content distribution network:
Object Host Simulates object behavior in the world by running scripts. User clients are object hosts that also know how to run a display.
Space A collection of one or more servers that simulate the world. Mediates interaction between objects, such as physics and communication.
Content Distribution Network Stores semi-permanent to permanent data and delivers it to the other components. For instance, meshes that are used to display objects are stored on a CDN and client object hosts can download them to view the world.
All of these components are required for a functioning world. Without object hosts, the world wouldn't have any objects in it. Without the space, object hosts wouldn't know how to interact and other centralized global services like physics wouldn't be available. Without the content distribution network, there wouldn't be a place to store and retrieve data lets us display the world.
These components can be put together in different ways to create different types of worlds. The sidebar shows some examples.
The rest of this document gives a little more detail on these components, but tries to remain non-technical. The description here should be sufficient for application developers. World developers may need to understand the components in more detail to customize their world. Greater detail can be found in the :ref:`world-architecture` of the :ref:`world-guide`. Finally, if you're looking to extend the Sirikata platform, check the :ref:`platform-components` in the :ref:`platform-guide`.
The space is what you might think of as the world around us: it isn't the objects but the set of rules they must follow and how they interact with each other. In Sirikata this boils down to only a small set of services: the space manages objects locations, physics simulation, lets objects learn about other nearby objects, and enables those objects to communicate with each other. All the rest of the functionality of the world can be built on this very small base.
Spaces may also provide additional services. For example, a world could function perfectly well with sounds handled entirely by exchanges between objects. However, it might be more cost effective to have the space manage sound to efficiently generate sound for each object that wants to listen.
Spaces can be simulated using a single server, but are commonly simulated across a number of space servers, enabling them to handle larger regions, more objects, and more clients.
An object host simulates objects, allowing them to specify their behavior in scripts and providing them access to spaces and CDNs. At their core, object hosts are simple: they embed a scripting language for objects and expose ways for the objects to connect to spaces and CDNs and usually provide some easier methods for interacting with other objects.
The examples in the sidebar suggest how object hosts might be used. In an open world, anybody running an object host can connect to the space. The owner adds their scripted objects, which connect to that space and start interacting with other objects. They might add code while they are in the world to extend the behavior of objects, perhaps teaching it how to interact with a new type of object or provide a new service to other avatars.
In the second example, a company is developing a game. Because they want complete control over how objects behave in the world, they run all the object hosts containing objects in the world (from mountains, to swords, to goblins), except for those with the players.
In both cases, clients are just a special type of object host that knows how to display the world and respond to user input. The object that manages this is the avatar. This means that clients and objects in the world aren't differentiated, both can be and are scripted using the same tools.
A graphical display isn't the only extension an object host can have. Object host can support a variety of plugins: display of the 3D world, input from the user, sound input and output, different scripting languages, access to permanent storage (e.g. disk), and interoperation with other systems (e.g. HTTP access) are just a few examples.
Content Distribution Network
The content distribution network stores and serves long-lived content the world requires to run. The most obvious example is mesh data, which often can't be distributed up-front (for instance, because users add objects with their own meshes to the world).
A "content distribution network" can be as simple as a web server, and in fact that is a common solution. The CDN really only needs to be able to serve requests for files. However, the CDN might be much more complicated, handling a very large number of users, intelligently serving data from servers near the source of requests, doing advanced processing of content (like simplification, conversion to progressive formats for streaming), and caching files to reduce the cost of running the CDN.
The Sirikata Ecosystem
Sirikata isn't a monolithic piece of software. At its most basic, Sirikata is an architecture and set of protocols that allow the components of that architecture to interact. Implementations of these components allow a world developer to collect and tie together all the pieces necessary to run a world.
The :ref:`general-architecture` describes the high level components required in a Sirikata virtual world and their basic functions. This document lists the known implementations of the different Sirikata components. This is a good reference for world developers: they will select one or more options from each category to pull together a world that suits their, and their user's, needs.
This is just a high level breakdown. For instance, the C++ implementation is plugin based and you can choose to turn features on or off, change which implementation you use, and interact with different external services. These options are described in more detail in the :ref:`world-guide` and in each implementation's documentation.
There is one source for the protocols that allow Sirikata components to interact. The repository is at http://github.com/sirikata/sirikata-protocol and is referenced by all implementations listed here. Note that some components which support distributed deployment (e.g. the C++ space server) have additional, internal protocols. Other implementations are not required or expected to support these internal protocols. Only protocols in the protocol repository should be used or relied on.
- C++ Space Server -- http://github.com/sirikata/sirikata -- Currently the only implementation. Easy setup for running a single server, but also supports large, distributed deployment.
- C++ Object Host -- http://github.com/sirikata/sirikata -- Plugin based scripting.
- .NET Languages (Mono) - embeds the Mono .NET runtime and exposes core C++ object host API to .NET. Depends only on the runtime and is therefore language agnostic.
- KataJS -- http://github.com/sirikata/katajs -- Runs in modern web browsers.
- WebSockets for communicating with space servers.
- WebGL for 3D graphics.
- WebWorkers support for parallelism, script isolation.
- HTML5 for UI and interaction.
So far, content distribution has been focused around HTTP based solutions.
- Web Server (e.g. Apache)
- Trivial implementation that just serves up static files.
- Good for centrally controlled content, e.g. not incorporating user generated content.
- Currently only CDN for KataJS since access from the browser requires using stock HTTP requests.
- Progressive HTTP CDN -- http://github.com/sirikata/sirikata
- Allows content to be intelligently chunked and progressively loaded.
- Scripts on top of web server, based on HTTP using additional headers.