Version 10 (modified by osg, 7 years ago)

--

Examples

Running the examples

The OpenSceneGraph has an ever growing number of examples available for developers to learn from, at last count (August 2007) there was 77 example programs. Following is a guide to gettting these examples running.

Once the OpenSceneGraph is installed you will need place the location where it was installed on the you systems paths environmental variables, and then download the demo data and set the OSG_FILE_PATH so that the file loading can locate the datasets. It is probably worth setting you autoexec.bat, .bashrc or.tcsh etc to pick up on these settings so that next time you log in everything is in easy reach.

  • Windows:
    set PATH=path;C:\OpenSceneGraph\bin
    set OSG_FILE_PATH=C:\OpenSceneGraph-Data;C:\OpenSceneGraph-Data\Images
    
  • Unix - bashrc:
    export PATH = ${PATH}:/home/myaccount/OpenSceneGraph/bin
    export LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
    export OSG_FILE_PATH = /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images
    
  • Unix - tcsh:
    setenv PATH ${PATH}:/home/myaccount/OpenSceneGraph/bin
    setenv LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
    setenv OSG_FILE_PATH /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images
    
  • MacOSX:
    setenv PATH "${PATH}:${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
    setenv DYLD_LIBRARY_PATH "${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
    setenv DYLD_BIND_AT_LAUNCH 
    setenv OSG_FILE_PATH "/home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images"
    

All the examples run on the commandline, most requiring parameters, such as what file to load, if you are in any doubt just run the application and it will either run, or provide help on what options it accepts. You can also print out full help my running the example with the keyword --help.

To run the examples in quite sucession, use the runexamples.bat script which can be found in the the root of the OpenSceneGraph distribution:

./runexamples.bat

Press Escape to close each application and move on to the next application.

Brief introduction to the examples

example thumbnail startup example description
osganimate osganimate --overlay Demonstrates the use of osg::AnimationPath for setting up animations for transform nodes and the usage of osg::OverlayNode. Three overlay modes can be specified as argument:
--overlay or --object OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
--ortho or --orthographic IEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
--persp or --perspective VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
osgautotransform
osgbillboard osgbillboard Demonstrates how to create the various types of billboard supported by the OpenSceneGraph. Billboards are typically used for trees or particles effects.
osgblendequation
osgcallback
osgcamera
osgcatch
osgclip
osgcompositeviewer
osgcopy Standard viewer with console output osgcopy cow.osg Demonstrates the use of deep vs shallow vs custom copying of scene graphs. A specialized CopyOp class is used to output all copying that takes place when performing a deep or shallow copy. This example allows for quick experimentation (in source) with the different CopyOp flags.
osgcubemap
osgdelaunay
osgdepthpartition
osgdepthshadow
osgdistortion
osgfadetext
osgforest
osgfxbrowser
osggeodemo
osggeometry
osghangglide osghangglide The hang glide demo creates a simple flying site (Don Burns local hang glide site in fact!), demonstrating how to create simple terrain, trees and skydomes, and how to implement a simple flight camera manipulator to allow the user to fly around.
osghud osghud glider.osg Very similar to the basic osgviewer demo, but adds an orthographic projection over the top of the main 3D view to create a head up display effect. Also demonstrates how to use osgText.
osgimpostor
osgintersection
osgkeyboard
osgkeyboardmouse
osglauncher
osglight
osglightpoint
osglogicop
osglogo
osgmanipulator
osgmotionblur
osgmovie
osgmultitexture
osgoccluder
osgpagedlod
osgparametric
osgparticle
osgparticleeffects
osgphotoalbum
osgpick
osgplanets
osgpoints
osgpointsprite
osgprecipitation
osgprerendercubemap
osgprerender
osgreflect osgreflect cow.osg An example of how to set up planar reflections using the standard multi-pass stencil buffer algorithm. This is all handled within the scene graph, so there is no need to hardwire multi-pass effects into your own application.
osgscalarbar
osgscribe osgscribe cow.osg An example of how to decorate your scene graph geometry for useful effects such as scribing. This demo uses two instances of your model, the first one uses the state values set in your scene graph, the second instance override the polygmode to render it as wireframe, and with a polygon offset to ensure it is seen from all angles. These two instance are grouped together and then are treated like any other scene graph.
osgsequence
osgshaders
osgshaderterrain
osgshadow
osgshadowtexture
osgshape
osgsimplifier
osgsimulation
osgslice
osgspacewarp
osgspheresegment
osgspotlight
osgstereoimage osgstereoimage left.rgb right.rgb An example of use node maks to select different parts of the scene graph for different traversals, in this case two separate images are drawn for the left and right eyes to generate a stereo 3D image from two flat images!
osgteapot
osgterrain
osgtessellate
osgtext osgtext An example showing how to creating the various different typs of text that the osgText library supports.
osgtexture1D
osgtexture2D
osgtexture3D
osgtexturerectangle
osgunittests
osgvertexprogram
osgvolume
osgwindows

Attachments