VR3Lib Documentation


The VR3Lib is a complete rendering and physical simulation library to be used in real-time virtual reality applications. In this section we briefly present the structure of the library, the user should refer to the specific classes documentation for a detailed description.

This library has been developed as an improvement of the VRLib library, used in the XVR virtual reality engine to manage rendering of virtual objects. The VRLib has not been extended, this is a full rewriting of the virtual reality library, only its structure and its interface has been somewhat preserved.

The old VRLib library was an all-around library for graphics, written using OpenGL. With OpenGL 3.0, the previous way of programming the graphical pipeline became obsolete and was finally removed from the core OpenGL profile (core functionalities). This library fully embraces the new programming model, uses only non-deprecated functionalities and is completely forward-compatible. Built-in physics support has been added to use this library as a single physics and graphics module, with no additional effort.

A scene in the VR3Lib library can be represented by a tree structure of objects. An object is an instance of the VR3Obj class and represent a virtual item. Objects may be moved, scaled, rotated, etc... The user may also simulate the objects physically (provided that physical parameters are available for the specified object in some file). Currently, only the AAM file format is supported both for geometric and rendering properties and for physical properties.

Objects represent items in the virtual world, but the graphical mesh, the material and the physical properties of an object depend upon the mesh(es) associated with it. Objects may be associated no mesh (pure transformation object) or more than one if multiple level of details are defined for the object.

Objects may be organized in a tree-like hierarchy. An object may have more than one child but only a single parent object. Children objects will have their transformations considered relative to their parent's one. When physically simulating, children object will be considered separate from their parents (except in case of joint).

Meshes, materials, textures and physical meshes are managed by static modules in order to avoid multiple loading of the same entity data.

A single mesh may be associated to multiple objects (scaled, rotated and translated differently) and is composed of one or more subsets. A subset is considered a set of triangles in a mesh which share the same material. Triangles in a mesh are drawn in the order they are encountered in the mesh file, both if sharing the same material or not. Subsets may be simulated using different objects that are connected by a parental relationship (and eventually fixed joints), but using subsets as portions of meshes we are able to save time during rendering because uniform parameters need not to be computed and loaded multiple times.

Built-in graphics capabilities include:

All those features may have been implemented also using the old VRLib, but the user had to write her own shaders for that purpose. If the built-in capabilities in VR3Lib are not enough, the user may still use her own shaders to obtain more convincing scenes.

The VR3Lib is implemented using some library in order to perform specific tasks like loading images in memory. In the following, we list the used libraries. Please note that those library symbols are exported in the resulting .lib file and the user may access them at will by using the provided header files.

In the following, a simple example is given that draws an object in front of the camera (2 units away):

  VR3Scene* scene;
  VR3Obj* obj;

  // Executed at startup
  OnInit() {

      scene = new VR3Scene(WIDTH,HEIGHT,60.0f);
      obj = new VR3Obj("obj.AAM");
      obj->SetPosition(0.0f, 0.0f, -2.0f);

  // Executed once per frame
  OnFrame() {

  // Executed on exit
  OnExit() {
      delete obj;
      delete scene;

 All Classes Namespaces Files Functions Variables Typedefs Friends Defines