OpenSceneGraph (OSG) is a cross platform C++/OpenGL library for real-time rendering of large 3D photo-realistic models.
The OpenSceneGraph homepage is at http://www.openscenegraph.org/.
(Never, *ever*, should OSG be confused with "OpenSG" which is at http://www.opensg.org/. ;-)
These are some projects and hacks I did using OSG. They're mostly spike solutions and should only be regarded as starting points for more elaborate solutions. Please send suggestions, questions, etc. to my e-mail address.
There is a separate page on projects I did using OpenSceneGraph.
An event handler that toggles bounding-sphere/geode bounding-box/drawable boundingbox and surface/vertex normals.
This reader for STL files (stereolithography) is a by-product of a project I did in 2004. There's also a writer but that is at this time (Feb 2008) not committed to OSG subversion.
Skull dataset; 511706 facets
Pelvis dataset; generated facet normals; 100850 facets
hand.zip dataset; 390305 facets
conrod.zip dataset; 6442 facets
A lot of simulators for remote controlled aircraft suffer the problem, that you can't very well make out the attitude of the aircraft once it's a certain distance away since it's merely a few pixels in size. Most simulators try to solve this problem by providing a zoom lens but this has the negative effect that you loose the sense of your surroundings since all you see is the model. This makes landing somewhat problematic.
My approach shown here is to provide a separate zoom lens in the center of the screen that shows the same scene as the surrounding window only with a smaller field-of-view. That way you can keep better track of your landing approach or where you're going.
As of Dec 2009 this code is part of the OSG repository.
This is a code snippet I wrote to outline objects in OSG. It uses the stencil buffer to create constant width lines around the silhouette of an object. It can be used to highlight objects or create a cartoon-like effect for characters especially when used with a cel-shader.
Mar 06 2004 I've converted the example to use the osgFX framework. The inner workings of osgFX make it necessary to manually activate stencil clear. The effect does this through a cull callback that activates stencil clear on its first invocation. This surely will fail if more than one RenderStage is used...
Apr 23 2004 Fixed a problem with the color material settings that caused the outline color not to show up correctly.
May 23 2009 Cleanup the code a bit for OSG-2.9. Please unpack the 20090523 tarball in your OSG directory and tweak the src/osgFX/CMakeFile.txt and examples/CMakeFile.txt files to include the outline code.
Nov 13 2009 Added setWidth
and setColor
methods to the 20091113 tarball. This FX works in the supplied osgoutline
example and is also picked up by the osgfxbrowser
but doesn't correctly work there because the latter doesn't setup the stencil buffer as required.
Below are some screenshots and links to .x models loaded with the DirectX file loader I'm working on. The models are intended to be used with the FMS Flying Model Simulator.
Some models have a flipped texture .bmp file. This is best solved by opening the file with xv or GIMP and flip it vertically. Alternatively the OSG loader can flip the coordinates using osgconv -O flipTexture <your-file.x>. Only geometry import has been tested so far but I made a best-effort to deal with unexpected content as well.
If you find a model that's giving you problems please send me an e-mail!.
You can find more files here or even more files here (head for Download/FMS). Be aware that some of the models are in .geo format which is not compatible with the .geo loader in OpenSceneGraph.
The code isn't currently maintained and won't run with OSG >= 0.9.
It's living on in the 'osgmovie' example.
MpegImageStream class and example
This is some work I've done regarding video textures and also to demonstrate how to use the OSG on-demand texture subloading. It's by no way complete but shows the concepts I hope. It's not that difficult anyway. Unfortunately I didn't have much time and/or drive to work on it a lot so essential features are still missing. My main concern is to move to another decoder library that supports more formats. I'm currently evaluating avifile and ffmpeg. Also high on the list is audio support.
The sample code creates a polygon and applies a MPEG texture to it. The software uses heroine warrior's libmpeg3 for decoding. (The name was chosen to avoid confusion with libmpeg2; it really only decodes MPEG-1 & -2.)
Unpack videotex.tar.gz
and have a look at the README
file for installation, it's all rather simple.
The timing is extremely simple right now, the decoder thread just sleeps for 1.0/fps
seconds between frames. This works pretty well for video only files but is a bit too fast for audio/video files that I tested. For these files the video stream should be sync'd to the audio signals (and skip frames as necessary) but that's not done yet.
On hardware that supports SGIS_generate_mipmap
(such as nVidia) you might want to use texture minification filter LINEAR
or NEAREST
to avoid mipmap generation when subloading. This severely slows down apply()
with full size video (e.g. PAL 720x576).
Please use the osgParticle library for serious work, it's much better and more complete.
ParticleSystem code and example
This is a particle system that I've been working on. It's a new implementation (instead of a wrapper around something existing) which has pros and cons.
The Pro is a IMHO clean integration with the scene graph; it behaves like a regular osg::Node
, is culled and can be moved about with a osg::Transform
. The update can be done transparently in an app-callback. On the Con side is that it's still missing a lot of features. But the structure is easily extended for better physics, more complex behaviour, and visual appearance.
Unpacking and make
should be all that's needed. The classes and their usage are briefly described in the README
file that comes with the tar ball.