REACTIVE SPACES API - DOCUMENTATION

All data and functions exist in a global object accessible as ReactiveSpaces or simple RS.


Settings

RS.BASEURL

Stores the base host/url for connecting to the desktop client. In most cases, this should not be changed. If you wanted to try launching the desktop app on another PC and then use its Kinect, it should theoretically work by changing this address.

Default value : "ws://localhost"


RS.LOCALPORT

Stores the port on which to connect to the desktop app. Only change this value if you needed to change the connection port in the desktop app.

Default value : 8080


RS.MESSAGE_DELAY

Stores the number of milliseconds delay required between each sent message. Shortening this value could cause instability and lag in the system and server. If you’re game requires messages more often than this, you should look at using a true multiplayer system.

Default value : 100

RS.SUPORTED_PLAYERS = 2;

Represents the maximum number of local players that will ever be tracked. Changing this value has no effect.

Default value : 2


RS.MOVEMENT_BLENDING

Boolean value denoting weather or not to blend skeleton frame data and create smoother joint movement. Turning this off can improve performance, but blended joint positions will no longer update.

Default value : true


Methods

RS.socketSupported

Stores weather or not the browser supports web sockets. If false, Reactive Spaces will not be able to connect to the desktop app or server.


RS.socket

Stores the current socket connection to the desktop app (if any).


RS.connected

Boolean value representing the current connection status of Reactive Spaces.


RS.lastMessage

UNIX timestamp denoting the last time a message was sent from Reactive Spaces to the desktop app.


RS.station

Stores the RS.StationProfile object representing the local station information. If no connection to the desktop app has been made, this value can also be null.


RS.remoteStations

Stores a list of RS.StationProfile objects representing the remote stations that are in the same game session.


RS.players

Stores a list of RS.Skeleton objects representing the current local players.


RS.remotePlayers

Stores a list of RS.Skeleton objects representing the current remote players.


RS.lastBlendUpdate

UNIX timestamp denoting the last time the blended skeleton data was updated.


RS.listeners

Stores all event listeners added to Reactive Spaces


RS.messenger

Provides basic error logging capabilities for Reactive Spaces.

Also defines a Global Message object which has an enumerator for message types defined as

Message.type = {“MESSAGE” : 0, “WARNING” : 1, “ERROR” : 2}


RS.appInfo

Stores information about the connected web app. Members are: name, version, maxPeers.

Default Value:{

name: "Default App Name",

version: 0,

maxPeers: 4

}


Methods

RS.Connect ( appName, appVersion, features, port )

appName : name of web app that is connecting
appVersion : version of app that is connecting (int or float). Only app instances with the same version will be matched on the server
features : list of features that are required by the app. Use enumerator RS.Features.
port (optional): connection port to use. If omitted, RS.LOCALPORT will be used

Attempts to connect to the Reactive Spaces Desktop App. Returns true or false depending on whether connection was successful or not.


RS.Disconnect ()

Disconnects from the desktop app and server.


RS.BlendUpdate ()

DUpdates the blended skeleton positions. Called automatically when RS.MOVEMENT_BLENDING is true on connection. Can be called manually on your apps update loop if desired.


RS.ActivateMessenger ()

Reactive Spaces provides an optional messenger system to display messages, warnings and errors easily.

Include the messenger in you project with

script src=” http://reactivespacesapi.com/lib/Messenger.js

And then call this function to upgrade RS.messenger to this advanced messenger. Post your own messages with RS.messenger.display( Messenge.type type, string message, string solution).


RS.addEventListener (event, callback)

event : string denoting the envent to listen to. Use enumerator RS.Events or see RS.Events in the documentation for a full list

callback : function pointer for function to be called when event fires


RS.removeEventListener (event, callback)

This function currently has no effect


RS.Send ( object )

Tobject: javascript object to send

Sends the given object to all stations in the current app session.


Utility Functions

RS.DrawSkeleton ( context, skeleton, color, blend )

Draws given skeleton on the given 2D context. Maps screen position to the bounds of the canvas.

context: valid 2D drawing context for an html 5 canvas

skeleton: valid skeleton object from ReactiveSpaces

color (optional): string canvas color identifier, default is "#FFF"

blend (optional): boolean - sets weather or not to use the blended skeleton. RS.MOVEMENT_BLEND must be set to true (default is false)


Types

RS.Skeleton ()

Describes the skeleton object that ReactiveSpaces uses to store Kinect data


RS.Skeleton.Update ( skeleton )

skeleton: the skeleton object to copy the data from

Updates the joint positions and data from another skeleton object. This is used for incoming data streams from the desktop.


RS.Skeleton.BlendUpdate ( deltaTimeS )

Blends previous skeleton with current skeleton. ****


RS.SkeletonJoint ( skeleton )

skeleton: the skeleton object to copy the data from

Describes a skeleton joint object


RS.SkeletonJoint.SetFromJoint ( joint )

joint: valid RS.SkeletonJoint object

Copies data of the given joint into this one


RS.SkeletonJoint.BlendUpdate ( deltaTimeS )

Called by ReactiveSpaces to update the smoothed screenPosition. Also updates joint velocities.


RS.Vector3 ( x, y, z )

x (optional): inital x value, default is 0

y (optional): inital y value, default is 0

z (optional): inital z value, default is 0

A simple object which defines a 3D point (x, y, z)


RS.Vector3.Set ( x, y, z )

x (optional): inital x value, default is 0

y (optional): inital y value, default is 0

z (optional): inital z value, default is 0

A simple object which defines a 3D point (x, y, z)


RS.Vector3.SetFromVector ( vector )

vector: object to copy from {x, y, z}

Sets the value of this vector from another vector. If x, y, or z are unset on the object it sets 0.


RS.Vector3.AddVector ( vector )

vector: object to add {x, y, z}

Adds given vector.


RS.Vector3.SubVector ( vector )

vector: object to subract {x, y, z}

Subtracts given vector.


RS.Vector3.MultiplyScalar ( scalar )

scalar: number to multiple vector by

Multiplies the vector by given scalar.


RS.Vector3.Normalize ()

Normalizes vector, length of vector = 1.


RS.Vector3.Length ()

Returns the length of the vector.


RS.Vector3.LengthSqd ()

Returns the squared length of the vector.


Enumerators

RS.Features

Shows what features are supported.

Kinect 0


RS.JointTypes

To pick joints from the skeleton object.

Head0
SHOULDER_CENTER 1
SPINE2
HIP_CENTER3
SHOULDER_LEFT4
SHOULDER_RIGHT5
ELBOW_LEFT6
ELBOW_RIGHT7
WRIST_LEFT8
WRIST_RIGHT9
HAND_LEFT10
HAND_RIGHT11
HIP_LEFT12
HIP_RIGHT13
KNEE_LEFT14
KNEE_RIGHT15
ANKLE_LEFT16
ANKLE_RIGHT17
FOOT_LEFT18
FOOT_RIGHT19


RS.MessageTypes

Enumerator for incoming web socket messages.

APP_INFO0
CUSTOM1
KINECT2
REMOTE_KINECT3
STATION_PROFILE4
PEER_CONNECT5
PEER_UPDATE6
PEER_DISCONNECT7
LOCAL_PLAYER_ENTER8
LOCAL_PLAYER_EXIT9
REMOTE_PLAYER_ENTER10
REMOTE_PLAYER_EXIT11
FEATURE_MISSING12


RS.Events

A simple list of event types dispatched by ReactiveSpaces.

connect
disconnect
localkinectT
remotekinect
message
featuremissing
stationlocal
stationconnect
stationupdate
satationdisconnect
localplayerenter
localplayerexit
remoteplayerenter
remoteplayerexit


Contact Information

Carleton University | Canal Building

Ottawa, Ontario

Zara Tooth

Ryan Bottriell

Matthew Fournier

Marco Brito