OpenSceneGraph (OSG) FAQs 1 thru 50

FAQs 1 thru 50 square72_blue.gif FAQs 101 thru 150 square72_blue.gif FAQs 101 thru 150 square72_blue.gif FAQs 151 thru 200 square72_blue.gif


    This unofficial Open Scene Graph (OSG) FAQ Part 1 ( 1 thru 50) is provided by Gordon Tomlinson , I hope you find the information contained with these FAQ's useful and helpful. If you have a tip, FAQ or code snippet you would like to share you can send it me at faqs@3dscenegraph.com and I will add to the FAQ, or if you spot an error in a FAQ or a change in OSG that makes a topic out dated let me know and I will get the items updated


     

  1. What is Open Scene Graph (OSG)
  2. Is OSG the Same as Open Scene Graph
  3. What does Open Scene Graph Give Me
  4. Where can I get the Latest OSG
  5. Is there an OSG Mailing list
  6. Is there an OSG User Forum
  7. Are there any OSG Tutorials
  8. What 3d  Formats Does OSG Support
  9. What Image Formats Does OSG Support
  10. What's Wrong with the Header Files in OSG
  11. Can I Make my Editor Recognize OSG Header File
  12. How Can I Retrieve the Bounding Box of an osg::Node
  13. How Can I Retrieve the Bounding Sphere of an osg::Node
  14. Can I compute a bounding sphere for only certain Nodes
  15. How Can I Position a osg::Node in my Scene.
  16. How Can Set the HPR of my osg::Node
  17. Why does OSG ignore my Near Far Clipping Planes
  18. How can I get the Current Near &  Far Clipping Planes
  19. Why are my Scaled Models Shaded Incorrectly
  20. How Can I Set the Debug Info Level
  21. How do I Create a Debug Message
  22. My Geometry and Points Seem to be Being Culled by OSG
  23. Does OSG have any Terrain Support
  24. My osg::Drawable, drawImplementation Function is Called Only Once, Why
  25. Compiler Warning C4541: 'dynamic_cast' used on polymorphic type
  1. How Can I get Syntax Colouring with Extension Less Headers
  2. Why is My Dynamic Geometry is Not Being Updated
  3. How Do Import file format Not Supported by OSG
  4. Does OSG have a Native Binary Format Such  like PFB's.
  5. What is osgconv
  6. What Arguements are Supported by osgconv
  7. Why do Gridlines Appear in PagedLOD Ground Texture
  8. What is the Relationship Between  osg::State/OpenGL context ID's
  9. Sharing Scene Views amongst Rendering Surfaces
  10. With multiple rendering windows, I get weird results & textures display incorrectly
  11. Can I use OSG without Producer
  12. Where is the reference manual and programmers guide for OSG
  13. Whats the difference between Open Scene Graph and  OpenSG
  14. Particle system looks strange when I position them in my scene
  15. Can I use OSG within an existing Renderer engine
  16. Does OSG Support Multiple Threads or Processes
  17. How Can I get a Borderless window on win32
  18. Where can I Get CVS From
  19. How to disable lighting on a Node
  20. How to Force lighting on a Node
  21. How to disable texturing on a Node
  22. How to enable texturing on a Node
  23. How to Enable wireFrame mode on a Node
  24. How to disable wireFrame mode on a Node
  25. Can I share a single HUD over Multiple Windows

 

Resources

 

**  What is OSG - Open Scene-Graph b


    Open Scene Graph also commonly known as OSG is an Open Source, cross platform graphics toolkit for the development of high performance graphics applications such as flight simulators, games, virtual reality and scientific visualization.

    OSG is based around the concept of a Scene-Graph, it provides an object oriented framework on top of OpenGL freeing the developer from implementing and optimizing low level graphics calls, and provides many additional utilities for rapid development of graphics applications.

    For more details on what Open Scene Graph is visit the OSG Web Site

     

**  Is OSG the Same as Open Scene Graphb

     

    In the 3d simulation world many of the people use OSG and Open Scene Graph interchangeably. So yes in the is it is the same thing but the acronym OSG is used else were out side the 3d simulation world for other meanings, a quick google will show this to be the case

    But in the 3d World if you use OSG most people will know what you doing

     

**  What Does OSG Give Meb

     

    The stated goal of Open Scene Graph is to make the benefits of scene graph technology freely available to all, both commercial and non commercial users. OSG is written entirely in Standard C++ and OpenGL, it makes full use of the STL and Design Patterns, and leverages the open source development model to provide a development library that is legacy free and focused on the needs of end users.

    The stated key strengths of Open Scene Graph are its performance, scalability, portability and the productivity gains associated with using a fully featured scene graph, in more detail:

    • Performance

      Supports view frustum culling, occlusion culling, small feature culling, Level Of Detail (LOD) nodes, state sorting, vertex arrays and display lists as part of the core scene graph. These together make the Open Scene Graph one of the highest performance scene graph available.
    • Productivity

      The core scene graph encapsulates the majority of OpenGL functionality including the latest extensions, provides rendering optimizations such as culling and sorting, and a whole set of add on libraries which make it possible to develop high performance graphics applications very rapidly. The application developer is freed to concentrate on content and how that content is controlled rather than low level coding.

     

    • Format Support

      OSG now states that it includes 45 separate plugin's for loading various 3D database and image formats.
       

      3D database loaders include

      • OpenFlight (.flt)
      • TerraPage (.txp) including multi-threaded paging support
      • LightWave (.lwo), Alias Wavefront (.obj)
      • Carbon Graphics GEO (.geo)
      • 3D Studio MAX (.3ds)
      • Peformer (.pfb)
      • Quake Character Models (.md2)
      • Direct X (.x)
      • Inventor Ascii 2.0 (.iv)
      • VRML 1.0 (.wrl)
      • Designer Workshop (.dw)
      • AC3D (.ac)
      • .osg Native OSG ASCII format.
      • .osg Native OSG banary Format

       

      Image loaders include

      • .rgb
      • .gif,
      • .jpg
      • .png
      • .tiff
      • .pic
      • .bmp
      • .dds
      • .tga
      • quicktime (under OSX).
      • Fonts (via the freetype plugin)


    • Node Kits
    • OSG also has a set of Node Kits which are separate libraries that can be compiled in with your applications or loaded in at runtime, which add support for

      • particle systems (osgParticle)
      • high quality anti-aliased text (osgText)
      • special effects framework (osgFX)
      • OpenGL shader language support (osgGL2)
      • large scale geospatial terrain database generation (osgTerrain)
      • navigational light points (osgSim)
      • osgNV ( support for NVidia's vertex, fragment, combiner, Cg shaders )
      • Demeter (CLOD terrain + integration with OSG)
      • osgCal (which integrates Cal3D and the OSG)
      • osgVortex (which integrates the CM-Labs Vortex physics enginer with OSG)



    • Portability

      The core scene graph has been designed to have minimal dependency on any specific platform, requiring little more than Standard C++ and OpenGL. This has allowed the scene graph to be rapidly ported to a wide range of platforms - originally developed on IRIX, then ported to:
       
      • Irix
      • Linux
      • Windows
      • FreeBSD
      • Mac OSX
      • Solaris
      • HP-UX
      • PlayStation2
         
    • Window Systems

      The core OSG library is completely windowing system independent, which  makes it easy for users to add their own window-specific libraries and applications on top.

      In the distribution thereis already the osgProducer library which integrates with OpenProducer, and in the Community/Applications section of this website one can find examples of applications and libraries written on top of GLUT, Qt, MFC, WxWindows and SDL. Users have also integrated it with Motif, and X.

    • Scalability

      OSG will not only run on portables all the way up to Onyx Infinite Reality Monsters, but also supports the multiple graphics subsystems found on machines like a multi-pipe Onyx

    ( Note the above is more or less pulled straight from the OSG Web Site

     

**  Where Can I Get OSG Fromb


    You can basically 2 main ways to get hold of OSG

    You can down load pre-compiled binaries from the OSG downloads page

    Or you can retrieve the source for OSG from a CVS repository and build it your self using one of the following methods

    • Command line checkout
    • WinCVS checkout
    • MacCVS Pro checkout
    • CVS Browsing and Commit Query's


    CVS command line checkout instructions

    • Login to the cvs server and indicate the repository location with:

      cvs -d :pserver:anon@openscenegraph.net:/cvs/osg login

    You can supply an empty password (just hit return).

    • Checkout the source code with:

      cvs -z 6 -d :pserver:anon@openscenegraph.net:/cvs/osg co OpenSceneGraph

    • Updates occur nearly daily to the OpenSceneGraph source code, so it is recommended to update frequently. Update from within the OpenSceneGraph source tree with :

      cd OpenSceneGraph
      cvs update -Pd

    The -P argument will prune empty directories and the -d argument builds new directories if they've been added.

    I personally prefer to use and can highly recommend  WinCVS

     

**  Is there a OSG Mailing Listb

     

    Yes thereare currently four public OSG  mailing lists:

    osg-users

    For support and discussion.

    osg-news

    For news of new releases.

    osg-cvs

    To be notified when commits are made to the CVS repository.
    (Note: this list is read-only)

    osg-submissions

    To submit code changes, bug fixes, enhancements or code additions.
    (Note All submissions must confirm to the Submissions Protocol)

     

**  Is there a OSG User Forumb

**  Are there any OSG Tutorialsb


    thereare several sets of tutorials covering basic aspects of OSG and use with certain node kits and GUI, the following are list as of July 05


    ( Note that some of these sites can be un-accessible from certain countries or at times not available all

      

**  What 3d Formats Does OSG Supportb


    OSG supports the following 3D database formats

    • OpenFlight (.flt)
    • TerraPage (.txp) including multi-threaded paging support
    • LightWave (.lwo), Alias Wavefront (.obj)
    • Carbon Graphics GEO (.geo)
    • 3D Studio MAX (.3ds)
    • Performer (.pfb)
    • Quake Character Models (.md2)
    • Direct X (.x)
    • Inventor As 2.0 (.iv)
    • VRML 1.0 (.wrl)
    • Designer Workshop (.dw)
    • AC3D (.ac)
    • .osg Native OSG ASCII format.
    • .osg Native OSG binary Format

    See the OSG distribution for the latest full list of supported formats
     

**  What Image Formats Does OSG Supportb

     

    OSG supports the following Image formats

    • .rgb
    • .gif,
    • .jpg
    • .png
    • .tiff
    • .pic
    • .bmp
    • .dds
    • .tga
    • quicktime (under OSX).
    • Fonts (via the freetype plugin)

    See the OSG distribution for the latest full list of supported formats

 

* 10  *  What's With the Header Files in OSGb

* 11  *  Can I Make my Editor Recognise OSG headersb


    Is thereany way I can get my editor to recognise those darn extension-less headers in OSG

    It all depends on your editor and platform, some possibilities include:

    • Visual Studio:
      OSG source includes a file called LANGEXT.DAT in the OSG/Visual Studio directory. See the documentation for instructions for how to use the file
       
    • Vim:
      Can be made to recognize the mode string, "-*-c++-*-", at the beginning of each header file. Start vim. type ":set runtimepath" to see where vim looks for scripts. You can make a file in any of these directories (for example, ~/.vim on Linux). Make the directory if it doesn't already exist, and make a file called scripts.vim in that directory. The contents of that file should be:

      if getline(1) =~ '-*-c++-*-'

      set filetype=cpp

      endif

     

    • Emacs:
      Should recognize the mode string right out of the box.
       
    • Nedit:
      Can be told to treat files as C++ based on their location in an include directory
       
    • Dev-C++:
      In Tools/Editor Options/General thereis an option "Use Syntax Highlighting". In the box below add ;;. The final line will look like this: c;cpp;h;hpp;;. This will enable syntax highlighting in all files without extension.
       

* 12  *  How Can I Retrieve  the Bounding Box of an osg::Nodeb


    OSG stores a bounding sphere for all internal nodes (osg::BoundingSphere)

    To get  a Bounding Box of an osg::Node have to convert the Bounding Sphere to a BoundingBox along the following line:

Code :

--


    osg::BoundingBox bbox;

    bbox.expandBy( m_node->getBound() );

     

 

    Note that OSG use Bounding Box's at the  Drawable leaves level.
     

* 13  *  How Can I Retrieve the Bounding Sphere of an osg::Nodeb

     

    OSG stores a bounding sphere for all internal nodes (osg::BoundingSphere)

    Simply call the following to get the bounding sphere:

Code :

--


    osg::BoundingSphere bsphere =  m_node->getBound();

     

 

     

* 14  *  Can I compute a bounding sphere for only certain Nodesb

     

    Yes you can use the   osg::Node::ComputeBoundingSphereCallback mechanism to do this

    void setComputeBoundingSphereCallback(ComputeBoundingSphereCallback* callback)

    You will need to derive your own class from override the osg::Node::ComputeBoundingSphereCallback then you ovveride the computeBound  function

    (virtual BoundingSphere computeBound(const osg::Node&) ) with this function you place your logic in to identify the nodes of interest etc. 

    I have not seen this used in an samples as yet.

     

* 15  * How can I Position my Nodes or Models within the Scene b

     

    To move a node in OSG you need to attach that node to an osg::PositionAttitudeTransform or osg::Transform ( if the node is note one of these types)

    For example using a osg::PositionAttitudeTransform postion a node ate x = 100.00, y = 250.0 and z = 75.0
     

Code :

--


    osg::PositionAttitudeTransform *transform = new osg::PositionAttitudeTransform;

    transform->addChild(  myNode );

    transform->setPosition( osg::Vec3( 100.0, 250.0, 75.0 ) );

     

 

    or if your node is already an  osg::PositionAttitudeTransform simply
     

Code :

--

 

    myNode->setPosition( osg::Vec3( 100.0, 250.0, 75.0 ) );

     

 

     

* 16  *  How Can I set the HPR of my OSG Nodeb

     

    To set the orientation of an node in OSG you need to attach that node to an osg::PositionAttitudeTransform or osg::Transform ( if the node is note one of these types)

    OSG does note provide nice convenience functions for setting HPR angles like Performer or Vega Prime supply

    In OSG you have to use Matrices or Quaternion's for example

    To set the Heading you can do something along the lines of:    
     

Code : Set heading

--

 

    transform->setAttitude(osg::Quat(osg::DegreesToRadians( heading ),osg::Vec3(0,0,1)));

     

 

          

    To set the Pitch you can do something along the lines of:      
        

Code : Set Pitch

--

 

    transform->setAttitude(osg::Quat(osg::DegreesToRadians( heading ),osg::Vec3( 1,0,0)));

     

 

         

    To set the Roll you can do something along the lines of:          
          

Code : Set Roll

--

 

    transform->setAttitude(osg::Quat(osg::DegreesToRadians( heading ),osg::Vec3(0,1,0)));

     

 

    Setting HPR all at once  you can do something along the lines of:


 

Code : Set Roll

--

 

    transform->setAttitude(osg::Quat( osg::DegreesToRadians( roll ),osg::Vec3(0,1,0),

                                   osg::DegreesToRadians( pitch ),osg::Vec3(1,0,0),

                                   osg::DegreesToRadians( heading ),osg::Vec3(0,01,0)));

     

 

     

* 17  *  Why does OSG ignore my Near Far Clipping Planesb

     

    Why does OSG ignore my Near Far Clipping Planes

    When using osgUtil::SceneView, OSG is set up by default such that near and far clipping planes are recomputed on the fly based on eye point and viewable scene. This means that your setting will be overwritten

    This is designed in OSG and is used  optimize the near/far range of the depth buffer, which might otherwise contain "z-fighting" artefacts if near and far are set to unreasonably small or large values, which is fine for certain applications for many others it is not fine and is a pain that catches many users out.

    Thankfully thereis a simple work around to this,  you can override this behaviour by calling:
     

Code :

--

 

    sceneview->setComputeNearFarMode( osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR );

     

 

    If you are using osgProducer::viewer use:

Code :

--

 

    viewer->wGetCullSettings->setComputeNearFarMode(

                              osgUtil
    ::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR );

     

 

     

* 18  *  How can I get the Current Near &  Far Clipping Planesb


    You can do something along the lines of:

Code :

--

 

    double nearclip = sceneView->getCullVisitor()->getCalculatedNearPlane();

    double farclip  = sceneView->getCullVisitor()->getCalculatedFarPlane();  

     

 


    also you can do the following:

       

Code :

--

 

    double d, nearclip = 0.0,  farclip = 0.0;

    sceneView->getProjectionMatrixAsFrustum( d, d, d, d, nearclip, d );    

    sceneView->getProjectionMatrixAsFrustum( d, d, d, d, d, farclip );

     

 

     

* 19  *  Why are my Scaled Models Shaded Incorrectlyb

     

    The problem you seeing is that your normals are being scaled along with your geometries and vertices.

    To keep your normals 'normalized',  you can set the following attribute on appropriate stateset(s):
     

Code :

--

 

    stateSet->setMode( GL_RESCALE_NORMAL, osg::StateAttribute::ON );

     

 

    Also you could consider using an osgUtil::SmoothingVisitor

     

* 20  *  How Can I Set the Debug Info Levelb


    You can do this by setting the OSG_NOTIFY_LEVEL environment variable to a higher level ( Levels in increasing levels of output )

    • ALWAYS
    • FATAL
    • WARN
    • NOTICE
    • INFO
    • DEBUG_INFO
    • DEBUG_FP  

    In code you can call the following with the level of output required

Code :

--

 

    osg::setNotifyLevel( osg::INFO );

     

 

     

* 21  *  How do I Create a Debug Messageb


    You can use the osg::Nofity class to output debug and informative information to the console window (default output)

    For example: 

     

Code :

--

 

    osg::notify( osg::NOTICE ) << "Error reading file  "

                                << srcFileName.c_str()

                                << "  "

                                << std::endl;

     

 

    Note the for the message to be displayed to the console the level must be equal to or less than level set by osg::setNotifyLevel

    Avaliable Levels in increasing levels of output

    • ALWAYS
    • FATAL
    • WARN
    • NOTICE
    • INFO
    • DEBUG_INFO
    • DEBUG_FP

     

* 22  *  My Geometry and Points Seem to be Being Culled by OSGb

     

    Yes its is quiet possible that OSG is culling away your geometry or points ( assuming you do not have LODS, that my be doing this), its another one of those little annoying gotchas that you come across ;(, ( This is where a OSG Programmers Guide would really really help)

    OSG by default uses small feature culling to cull out objects that occupy a predetermined screen size.

    This is a valuable feature for models with many details which do not contribute to the visual quality of the model when viewed from a distance. You can completely disable small feature culling by defining the cullingMode on osgUtil::SceneView with:

Code :

--

 

    osg::CullStack::CullingMode cullingMode = sceneview->getCullingMode();

     

    cullingMode &= ~ ( osg::CullStack::SMALL_FEATURE_CULLING  );