Version 43 (modified by rsmeenk, 4 years ago)

--

Examples

Running the examples

The OpenSceneGraph has an ever growing number of examples available for developers to learn from. Following is a guide to getting these examples running.

Once the OpenSceneGraph is installed you will need to place the location where it was installed on the system paths environmental variables. Also download the demo data and set the OSG_FILE_PATH environment variable so that the example datasets can be found by OSG. It is probably worth setting your autoexec.bat, .bashrc, .tcsh, etc to pick up on these settings so that next time you log in everything is in easy reach. Below are examples for the different platforms on how to set up your environment. The examples are not built by default, use the cmake utility and set the option to enable building of the example applications. To build them, run cmake with the following parameter: -DBUILD_OSG_EXAMPLES=1

  • 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 from the command-line. Most require parameters to be passed, 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 option --help.

To run the examples in quick succession on Windows, 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. On Unix, you should be able to use

sh ./runexamples.bat

Brief introduction to the examples

Example Screenshot Command Line Description
osg2cpp.cpp
osganimate.cpp 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 VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
--persp or --perspective VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
osganimationmakepath.cpp
osganimationmorph.cpp
osganimationnode.cpp
osganimationskinning.cpp
osganimationsolid.cpp
osganimationtimeline.cpp
osganimationviewer.cpp
osgautocapture.cpp
osgautotransform.cpp
osgbillboard.cpp osgbillboard Demonstrates how to create the various types of billboard supported by the OpenSceneGraph. Billboards are typically used for trees or particles effects.
osgblendequation.cpp
osgbrowser.cpp
osgcallback.cpp
osgcamera.cpp
osgcatch.cpp
osgcegui.cpp
osgclip.cpp
osgcluster.cpp Master:
osgcluster -m cow.osg
Slave:
osgcluster -s cow.osg
Demonstates basic clustering of machines across a local area network using UDP packets to send camera position updates from a master viewer to slave viewers.
osgcompositeviewer.cpp osgcompositeviewer cow.osg -3 Demonstrates the use of the compositeviewer.
-1 Single view with fountain.osg and a statshandler and trackballmanipulator
-2 Two views each on a different screen sharing the same scene. First view trackballmanipulator and statesetmanipulator. Second view statshandler, trackballmanipulator and a pickhandler.
-3 Three views within a single window. Window and graphics context manually created. First view (left bottom) with several event handlers. Second view (right bottom) with a trackballmanipulator and a pickhandler. Third view (upper half) with cessnafire.osg and a trackballmanipulator.

-s SingleThreaded?
-g CullDrawThreadPerContext?
-c CullThreadPerCameraDrawThreadPerContext
osgcopy.cpp 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.cpp
osgdatabaserevisions.cpp
osgdelaunay.cpp
osgdepthpartition.cpp
osgdepthpeeling.cpp
osgdistortion.cpp Shows how to use offscreen rendering (FBOs and PBOs) to distort the rendering of a scene arbitrarily. It is also demonstrated how to calculate a dome distortion correction.
osgdrawinstanced.cpp
osgfadetext.cpp
osgfont.cpp
osgforest.cpp
osgfpdepth.cpp
osgfxbrowser.cpp
osggameoflife.cpp
osggeodemo.cpp
osggeometry.cpp
osggeometryshaders.cpp
osghangglide.cpp 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.
osggpx.cpp
osghud.cpp 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.
osgimagesequence.cpp
osgimpostor.cpp
osgintersection.cpp
osgintrospection.cpp
osgkdtree.cpp
osgkeyboard.cpp
osgkeyboardmouse.cpp
osglauncher.cpp
osglight.cpp
osglightpoint.cpp
osglogicop.cpp
osglogo.cpp
osgmanipulator.cpp
osgmemorytest.cpp More osgmemorytest details
osgmotionblur.cpp
osgmovie.cpp
osgmultiplerendertargets.cpp
osgmultitexture.cpp
osgmultitexturecontrol.cpp
osgmultiviewpaging.cpp
osgoccluder.cpp
osgocclusionquery.cpp
osgoit.cpp
osgpackeddepthstencil.cpp
osgpagedlod.cpp
osgparametric.cpp
osgparticle.cpp
osgparticleeffects.cpp
osgparticleshader.cpp
osgpdf.cpp depends on poppler and Cairo
osgphotoalbum.cpp
osgpick.cpp
osgplanets.cpp
osgpoints.cpp
osgpointsprite.cpp
osgprecipitation.cpp
osgprerender.cpp
osgprerendercubemap.cpp
osgQtWidgets.cpp
osgreflect.cpp 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.
osgrobot.cpp
osgscalarbar.cpp
osgscreencapture.cpp
osgscribe.cpp 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.cpp
osgshadercomposition.cpp
osgshadergen.cpp
osgshaders.cpp
osgshaderterrain.cpp
osgshadow.cpp Demonstrates diverse techniques for real-time shadow generation. More osgShadow
osgshape.cpp
osgsharedarray.cpp
osgsidebyside.cpp
osgsimplifier.cpp
osgsimulation.cpp
osgslice.cpp
osgspacewarp.cpp
osgspheresegment.cpp
osgspotlight.cpp
osgstaticviewer.cpp
osgstereoimage.cpp 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!
osgstereomatch.cpp
osgteapot.cpp
osgterrain.cpp
osgtessellate.cpp
osgtext.cpp osgtext An example showing how to create the various types of text that the osgText library supports.
osgtext3D.cpp
osgtexture1D.cpp
osgtexture2D.cpp
osgtexture3D.cpp
osgtexturerectangle.cpp
osgthirdpersonview.cpp
osgthreadedterrain.cpp
osgunittests.cpp
osgvertexprogram.cpp
ViewerCocoa.mm
osgviewerFLTK.cpp
osgviewerFOX.cpp
osgviewerGLUT.cpp
osgviewerGTK.cpp
osgviewerMFC.cpp
osgviewerQT.cpp
osgviewerQTcontext.cpp
osgviewerQTwidget.cpp
osgviewerSDL.cpp
osgviewerWX.cpp
osgvirtualprogram.cpp
osgvnc.cpp depends on libvnc
osgvolume.cpp More osgVolume details
osgwidgetaddremove.cpp
osgwidgetbox.cpp
osgwidgetcanvas.cpp
osgwidgetframe.cpp
osgwidgetinput.cpp
osgwidgetlabel.cpp
osgwidgetmenu.cpp
osgwidgetmessagebox.cpp
osgwidgetnotebook.cpp
osgwidgetperformance.cpp
osgwidgetprogress.cpp
osgwidgetscrolled.cpp
osgwidgetshader.cpp
osgwidgetstyled.cpp
osgwidgettable.cpp
osgwidgetwindow.cpp
osgwindows.cpp

Attachments