Vrpn 2 Ogre User's manual
Vrpn2Ogre User Documentation

Vrpn2Ogre is a software that takes events from OIS and VRPN and executes actions on a 3D displayed by Ogre. The behavior of the software is described by a simple script described in that documentation.

You can download it here.

Contents

1. Installation

2. Usage

3. Scripting language

4. Vrpn2Ogre License

1. Installation

1.1. Windows

Windows package is a simple ZIP containing all necessary dependencies. Just unzip it and executes the Vrpn2Ogre.exe executable from the destination directory. If the programs fails it's likely you need to install the Visual C++ dependencies from http://www.microsoft.com/download/en/details.aspx?id=5555 .

1.2. MacOS X

MacOS X package is a mountable disk (.dmg) that you can mount. Copy the Vrpn2Ogre application wherever you want and launch it. You can also directly launch the application from the mountable disk.

1.3. Linux

CMake compilation is working fine under Linux Ubuntu Oneiric. Packages were made using CPack under Linux Ubuntu Oneiric:

1.4. CMake

Other operating systems are not yet supported but can probably be build using CMake and the source. However, you have to do the packaging all by yourself. The package should includes:

The CMake script includes packaging and testing targets.

2. Usage

2.1. Command-line arguments

    Usage: vrpn2ogre [-c file] [-config|[-fs off|on] [-vm Mode]]
            [-stereo mode [-invert] [-eyespacing d] [-focal l] [-screenwidth w] [-fixfocal]]
            [--] [filename]
        -c file        Parse the given configuration file (default is config.cfg)
        -config        Activates the Ogre configuration window at startup
        -fs off|on     Turn on/off full screen mode (default is on)
        -vm Mode       Set the default video mode (default is 1280x1024)
        -stereo mode   Launch the program in stereoscopic mode (available modes
            are: none, sidebyside, verticaldual, ivertical, ihorizontal, icheckboard
            anaglyphrc, anaglyphyb)
        -invert        invert left and right camera in stereo mode
        -eyespacing d  set the spacing between two eyes (default 0.06 meter)
        -focal l       set the focal length (default infinite)
        -screenwidth w set the real size of the screen (default not used)
        -fixfocal      fix the focal plane position
        filename       Specifies the scene file (default default.cfg)
        --             Disable argument parsing
    

2.2. Key commands

By default, four actions are connected to key presses, they are:

2.3. Ogre configuration files

Vrpn2Ogre relies on 2 configurations files for the Ogre library: plugins.cfg and resources.cfg. You probably won't have to change these files except if you want to use non-shipped Ogre Plugins or you want to add extra materials. For a detailed description of thoses files, please read the Ogre3D wiki (http://www.ogre3d.org/tikiwiki).

2.4. General configuration file

Vrpn2Ogre command-line options can be given into a configuration file. The default file is config.cfg from the Vrpn2Ogre directory. More configuration files can be passed through the -file option at the command-line. The files are parsed according to the order given at command-line.

E.g., vrpn2ogre -vm 300p -c cfg1.cfg -invert -c cfg2.cfg -fs off will force full screen mode off (last argument) then options specified in cfg2.cfg file (except full screen mode) then stereo mode inversion (if not forced by cfg2.cfg) then the options specified in cfg1.cfg then 300p video resolution and finally options from config.cfg.

The possibles keys in that configuration files are:

Available modes for the stereo key are (case-insensitive):

An example of configuration file can be found in doc/samples/config.cfg:

# This file is part of Vrpn2Ogre.
# Copyright (C) 2012 Inria
#
# Vrpn2Ogre is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# Vrpn2Ogre is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with Vrpn2Ogre in the doc directory.
# If not, see <http://www.gnu.org/licenses/>.
#
# ///
# /// @file config.cfg
# ///
# /// VRPN2Ogre demo: Sample configuration file for Vrpn2Ogre
# ///
# /// @date   Created on: 24 feb. 2012
# /// @author Damien Martin-Guillerez <damien.martin-guillerez@inria.fr>
# ///
# This a classic key = value ini configuration file
# Possible values are either enum, real or boolean (true/on or false
# off - case-insensitive)

###############################################################################
## Screen set-up 
###############################################################################

# Turn on/off Ogre Configuration window at startup
ShowConfig = Off

# Turn on full screen mode
FullScreen = On

# Set the default resolution
# The value is a resolution in "width x height" format or Height"p" format
# to describe a 16/9 resolution
Resolution = 1080p

###############################################################################
## Stereoscopie set-up 
###############################################################################

# Stereo mode configuration (enum)
#
# Available modes are (case-insensitive):
# None                      Turn off stereo (default).
# Horizontal Side By Side   Left and right camera images are displayed on a
#                           half of the screen horizontally.
#                           Aliases: SideBySide, HorizontalDual
# Vertical Side By Side     Left and right camera images are displayed on a
#                           half of the screen vertically.
#                           Alias: VerticalDual
# Vertically interlaced     Left and right camera images are interlaced
#                           vertically.
#                           Alias: iVertical
# Horizontally interlaced   Left and right camera images are interlaced
#                           horizontally.
#                           Alias: iHorizontal
# Checkboard interlaced     Left and right camera images are interlaced
#                           using a checkboard pattern.
#                           Alias: iCheckboard
# Anaglyph Red/Cyan         Stereoscopie is performed mixing red and cyan
#                           color (for use with red and cyan glasses).
#                           Aliases: Anaglyph RC, AnaglyphRC
# Anaglyph Yellow/Blue      Sterescopie is performed mixing yellow and blue
#                           color (for use with yellow and blue glasses).
#                           Aliases: Anaglyph YB, AnaglyphYB
Stereo = None

# Inverse left and right camera in stereo mode (boolean - default off)
InverseStereo = Off

# Set the distance between the two eyes in meter (real - default 0.06)
EyesSpacing = 0.06

# Set the focal length in meter (real or infinite - default 10)
FocalLength = 10 #inf / infinite for infinite value

# Set the screen width in meter
# ScreenWidth = 1.10

# Fix the focal plane position
# FixFocal = false

3. Scripting language

As described by the command-line arguments section, a file describing the demo can be passed as argument to Vrpn2Ogre. The default file used is default.cfg in the root directory of the application. This section describes its syntax. An example of script is given by doc/samples/xwing-scene.cfg:

# This file is part of Vrpn2Ogre.
# Copyright (C) 2012 Inria
#
# Vrpn2Ogre is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# Vrpn2Ogre is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with Vrpn2Ogre in the doc directory.
# If not, see <http://www.gnu.org/licenses/>.
#
# ///
# /// @file xwing-scene.cfg
# ///
# /// VRPN2Ogre demo: Scene and demo construction for the X-Wing in a water swamp demo
# ///
# /// @date   Created on: 3 jan. 2012
# /// @author Damien Martin-Guillerez <damien.martin-guillerez@inria.fr>
# ///
scene {
    camera.actions()

    ground(-50, 0.2)
    friction(0)
    forcefield("gravity", [0, -9.8, 0])
    # light
    light.set()
    # rock terrain
    terrain.rock([-400, -90, -4880])
    # Add a sky, sun & fog
    sky("Examples/SpaceSkyPlane", 50)
    fog([.9,.9,.9], 10, 500)

    # Water
    water("Water")
    light.animate()

    # X-Wing
    object("X-Wing", "xwing.mesh")
    object.fit("X-Wing", 40)
    object.position("X-Wing", [0,0,-150])
    object.roll("X-Wing", -3.14159/8)
    object.yaw("X-Wing", -3.14159/8)
   
    # Set the X-Wing to be an object with a mass :)
    object.collide("X-Wing", true)
    object.mass("X-Wing", 100000)
}


# Connect VRPN event, Luke, may the force be with you!
VRPN.Analog[device = "Analog0@localhost"] {
    print("May the force be with you
")
    object.force("X-Wing", "luke", [0,300000*channel[0],0])
}

# Reset
KeyPress[keyCode="r"] {
    print("Resetting the settings of the X-Wing
")
    object.force("X-Wing", "luke")
    object.position("X-Wing", [0,0,-150])
}

3.1. Language syntax

The language used to described the event can be expressed as:

        (Event [Guard] '{' Action* '}')*
    

A sharp '#' will start a line commentary (ending with a new line). Otherwise spaces and new lines have no special meanings.

Where Event is either 'scene' (in which case there is no guard and the actions will be executed at startup) or an event description:

        Event        = Identifier ( '[' (Argument (',' Argument)* )? ']' )?
                     | 'scene'
        Argument     = Identifier '=' Expression
    

A Guard is an expression that returns a boolean to determines whether the actions have to be executed or not:

        Guard        = Expression
        Expression   = Identifier '(' ArgumentList? ')'
                     | Expression OpIdentifier Expression
                     | OpIdentifier Expression | '(' Expression ')' | Value
                     | '[' ArgumentList ']'
        ArgumentList = (Expression ( ',' Expression )* )
    

And finally an action is a function call or an affectation:

        Action       = Identifier '(' ArgumentList? ')'
                     | Identifier '<-' Expression
    

Of course, in an expression, the parenthesis serves to specifies priorities between operators, the default priority is left operator first (e.g., a op1 b op2 c <=> ((a op1 b) op2 c)). The bracket ('[' and ']') are used to delimit an array.

The last part of the syntax is the definition of Value, Identifier and

        OpIdentifier     = OpChar+
        OpChar           = '+' | '-' | '/' | '*' | '|' | '!' | '@' | '%' | '$'
                         | '<' | '>' | ':' | '&' | '^' | '{' | '}'
        Identifier       = SimpleIdent (. SimpleIdent)*
        SimpleIdent      = [a-zA-Z_][a-zA-Z0-9_]*
        Value            = Integer | Real | Boolean | Null | String | Dereference
        Integer          = [0-9]+
        Exponent         = [eE]Integer
        Real             = Integer'.'(Integer)?(Exponent)? | '.'Integer(Exponent)?
        Boolean          = true | false  (case-insensitive)
        Null             = null |  (case-insensitive)
        String           = '"' StrChar* '"'
        StrChar          = [^"\] | '\''"' | '\' '\' | '\' [^"\]
        Dereference      = Identifier ('[' Expression ']')*
    

A dereference permit to access parameters of events (see section below) or variable previously affected (in case of collision with event parameter name, the event parameter take precedence and the mem operator should be used to access the variable). The brackets in a dereference is to access array elements.

3.2. Available events

All events have a parameter 't' which is the internal time at which the event was emitted. Each event kind has their own parameters, some of which can be used to filter events to receive in the configuration file. For example, if a event A has two parameters b and c, b is a parameter usable for filtering, then we can write "A" to acts on every occurrence of an event A or "A[b = 1]" to acts only when the b parameters is 1. In any subsequent expression, 'a' or 'b' identifier will be replaced by the value of the a or b parameter of the event "A". There is two kinds of event currently supported: KeyPress (events::KeyPressEvent) and VRPN (events::VRPNEvent).

KeyPress events are emitted when a key is pressed. Its only parameter is:

VRPN events are of three flavors: VRPN.Button (handle VRPN Button events), VRPN.Analog (Analog device events) and VRPN.Tracker (Tracker events). They all share a device parameter that is a string describing the device and passed to the VRPN library (such as Analog0@localhost) (IN and OUT). The specific parameters are only for sensing (not for filtering events):

3.3. Available actions

Several actions are usable in the scripts. Some of them are usable only in the "scene" section (not in response to events) and they are marked by a star (*) in the list of all actions:

General purpose actions

3D engine actions

Physical actions

Beware that the physical model is very simple (based on bound box).

3.4. Available operators

General purpose operators

3D engine operators

Physical engine operators

4. Vrpn2Ogre License

Vrpn2Ogre is copyright © 2012 Inria and licensed under the GNU Lesser General Public License. Vrpn2Ogre use sources from the Ogre3D Stereoscopy Manager from Mathieu Le Bar of AXYZ-IMAGES and the cppunit.cpp file from Robert Emerson which are distributed under the BSD Licensed. It also uses code from the WaterMesh sample of the Ogre3D library which is free of use (Copyright © 2000-2009 Torus Knot Software Ltd).

This section contains the full text for the applied licences.

4.1. GNU Lesser General Public License

                   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.


  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

  0. Additional Definitions.

  As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

  "The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

  An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

  A "Combined Work" is a work produced by combining or linking an
Application with the Library.  The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

  The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

  The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

  1. Exception to Section 3 of the GNU GPL.

  You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

  2. Conveying Modified Versions.

  If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

   a) under this License, provided that you make a good faith effort to
   ensure that, in the event an Application does not supply the
   function or data, the facility still operates, and performs
   whatever part of its purpose remains meaningful, or

   b) under the GNU GPL, with none of the additional permissions of
   this License applicable to that copy.

  3. Object Code Incorporating Material from Library Header Files.

  The object code form of an Application may incorporate material from
a header file that is part of the Library.  You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

   a) Give prominent notice with each copy of the object code that the
   Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the object code with a copy of the GNU GPL and this license
   document.

  4. Combined Works.

  You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

   a) Give prominent notice with each copy of the Combined Work that
   the Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the Combined Work with a copy of the GNU GPL and this license
   document.

   c) For a Combined Work that displays copyright notices during
   execution, include the copyright notice for the Library among
   these notices, as well as a reference directing the user to the
   copies of the GNU GPL and this license document.

   d) Do one of the following:

       0) Convey the Minimal Corresponding Source under the terms of this
       License, and the Corresponding Application Code in a form
       suitable for, and under terms that permit, the user to
       recombine or relink the Application with a modified version of
       the Linked Version to produce a modified Combined Work, in the
       manner specified by section 6 of the GNU GPL for conveying
       Corresponding Source.

       1) Use a suitable shared library mechanism for linking with the
       Library.  A suitable mechanism is one that (a) uses at run time
       a copy of the Library already present on the user's computer
       system, and (b) will operate properly with a modified version
       of the Library that is interface-compatible with the Linked
       Version.

   e) Provide Installation Information, but only if you would otherwise
   be required to provide such information under section 6 of the
   GNU GPL, and only to the extent that such information is
   necessary to install and execute a modified version of the
   Combined Work produced by recombining or relinking the
   Application with a modified version of the Linked Version. (If
   you use option 4d0, the Installation Information must accompany
   the Minimal Corresponding Source and Corresponding Application
   Code. If you use option 4d1, you must provide the Installation
   Information in the manner specified by section 6 of the GNU GPL
   for conveying Corresponding Source.)

  5. Combined Libraries.

  You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

   a) Accompany the combined library with a copy of the same work based
   on the Library, uncombined with any other library facilities,
   conveyed under the terms of this License.

   b) Give prominent notice with the combined library that part of it
   is a work based on the Library, and explaining where to find the
   accompanying uncombined form of the same work.

  6. Revised Versions of the GNU Lesser General Public License.

  The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

  Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

  If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

4.2. BSD License text for the Ogre3D Stereoscopy Manager

Copyright (c) 2008, Mathieu Le Ber, AXYZ-IMAGES
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the AXYZ-IMAGES nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Mathieu Le Ber ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Mathieu Le Ber BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

4.3. BSD License text for the cppunit.cpp file

Copyright (c) 2008, Robert Emerson
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Robert Emerson nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ROBERT EMERSON ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ROBERT EMERSON BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.