![]() |
VR-Forces 4.6.1 Class Documentation
|
This example shows how to create an OpenSceneGraph application. This particular example demonstrates the structure of the scene-graph and the minimum amount of code to start rendering.
Above the OpenGL layer is OpenSceneGraph, an API that provides scene organization functions as well as data management, LOD management, file loaders and other much more. With OSG we organize 3D geometry into a "scene graph", and provides functions for traversing the graph and making the appropriate calls to OpenGL to render the scene.
The example creates a single piece of geometry for display; a cube. When run, the user can grab, move and spin the cube using the mouse. This tutorial uses a default viewer for rendering the scene and accepting user input. Much of this setup code is hidden from us by the viewer's default settings making this application very lean.
Of particularly interest in this tutorial is the structure of the scene-graph. There are two basic types of objects in the scene-graph; Drawables and Nodes. Drawables hold the primitive/geometry structures, such as vertices, normals, colors, texture-coordinates, etc. Nodes hold the OpenGL states, such lighting, texturing, wire-frame, etc. Derived from Nodes are two basic objects; Groups and Geodes. Groups are containers that hold Nodes. Geodes are containers that hold Drawables. Because Geodes are Nodes, Groups can contain Geodes. The structure of a scene-graph can be thought of as such: Groups make up the branches, Drawables are the leaves, and Geodes are sort-of the 'twig' between the branches and leaves.
In this application we have one Group being the root of the graph, one Geode is made a child of the Group, and one Drawable is made a child of the Geode.
To display the scene we create a Viewer and use its default settings. We give the root of our graph to the Viewer and call run.
VR-Vantage includes pre-built versions of the example application. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
This example is an application. You can run it by running ./bin/exampleOsgSimple.exe (on Windows) or ./bin/exampleOsgSimple (on Linux). For more information about running examples, please see Running Applications and Examples.