xarray / osgrecipes Goto Github PK
View Code? Open in Web Editor NEWOpenSceneGraph (OSG) Recipes
OpenSceneGraph (OSG) Recipes
osgRecipes ============= The osgRecipes project includes different recipes written with OpenSceneGraph (OSG) and can help developers work with this famous 3D rendering engine, as well as other auxiliary libraries. The osgRecipes project itself is in the Public Domain, but some of its recipes may be under other licenses. This project is also the source code repository of Rui Wang & Xuelei Qian's book `OpenSceneGraph 3.0 Cookbook`, Packt Publishing, 2012. You may read more details or order this book at: http://www.packtpub.com/openscenegrap-3-for-advanced-3d-programming-using-api-cookbook/book ------------ Installation ------------ 1. Use CMake (or cmake-gui) to build makefiles or solutions of the recipes # cmake <recipe_dir> -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<install_dir> 2. Run 'make' to build and install all recipes # make # make install 4. Copy data files from both cookbook and integrations into the binary directory. # cp <recipe_dir>/cookbook/data/*.* <install_dir>/bin # cp -r <recipe_dir>/integrations/data <install_dir>/bin 5. Have fun! ------------ Cookbook ------------ You may have to download and compile these third-party dependencies to test all the recipes: * CEGUI: http://www.cegui.org.uk * NVIDIA Cg: http://developer.nvidia.com/cg-toolkit * DirectInput (Windows only): http://msdn.microsoft.com/en-us/directx/aa937788 * GLUT: http://www.opengl.org/resources/libraries/glut * NVIDIA Physx (version 2.8.x): http://developer.nvidia.com/physx-downloads * Qt (version 4): http://qt.nokia.com/products * FireBreath: http://www.firebreath.org/display/documentation/FireBreath+Home ------------ Integrations ------------ This section will show you how to integrate OSG with different kinds of libraries and SDKs. These libraries can add extra functionalities like special effects, visual components and interaction methods to your OSG scene and greatly improve the performance of the applications. These libraries must be free for downloading and for non-commercial purpose of use. The license of the example code may vary according to the license of the third-party library if it does not fit the public domain. The third-party libraries that can be embedded with OSG are listed here for downloading: * AGG (the anti-grain geometry library for 2D rendering): already included in the source code * ALVAR (virtual and augmented reality develop library): http://virtual.vtt.fi/virtual/proj2/multimedia/alvar/index.html * AntTweakBar (a light and intuitive GUI framework): http://www.antisphere.com/Wiki/tools:anttweakbar * AssImp (a library to import various well-known 3D model formats): http://assimp.sourceforge.net/ * Awesomium (a web-browser framework for in-app browsing and HTML UIs): http://awesomium.com/ * Box2D (a 2D physics engine for games): http://box2d.org/ * Bullet (A professional multiphysics library): http://bulletphysics.org/wordpress/ * FreeImage (a library supporting popular image formats): http://freeimage.sourceforge.net/ * GUIChan (a lightweight GUI framework): already included in the source code * libGizmo (gizmo control library for 3D object manipulation): https://github.com/CedricGuillemet/LibGizmo * MicroPather ( a path finder and A* solver): already included in the source code * Microsoft DirectWrite (a text-layout and glyph-rendering API): in the Windows SDK * Microsoft Kinect SDK: http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx * MyGUI (a fast, flexible and simple GUI): http://mygui.info/ * NanoVG (Antialiased 2D vector drawing library): https://github.com/memononen/nanovg * ngPlant (a plant modeling software): core library already included in the source code * NVIDIA PhysX (a well-rounded physics engine, version 3.2): http://developer.nvidia.com/physx-downloads * OpenNI (natural interaction devices middleware, including Kinect): http://www.openni.org/ * OTL (Oracle, Odbc and DB2-CLI template library): already included in the source code * PhysFS (PhysicsFS, provide abstract access to various archives): http://icculus.org/physfs/ * RecastNavigation (Famous navigation-mesh toolset for games): https://github.com/memononen/recastnavigation * RVO2 (Reciprocal collision avoidance for multi-agent simulation): http://gamma.cs.unc.edu/RVO2/ * Spark (a crossplatform particle engine): http://spark.developpez.com/ * Sundog SilverLining & Triton (Weather & ocean rendering commercial middleware): http://www.sundog-soft.com * Swift++ (a collision detection package): already included in the source code * TUIO (a common API for tangible multitouch surfaces): already included in the source code * VLC (a cross-platform multimedia player and framework): http://www.videolan.org/vlc/ * To be continued... ------------ Contributing ------------ Any suggestions and contributions are welcomed all the time. :-)
Hello.
I have only one node in scene, but i have applied shaders to it using
osg::StateSet* stateset = model_node->getOrCreateStateSet();
stateset->setAttributeAndModes( program, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
It seems that the ant tweak bar window appears with a lot of problems (black / white and the labels cannot be distinguished).
Is it tested if there are shaders applied to the scene ?
thank you for your time.
Hi Array:
i want to integrate openGL code inside OSG., and i have read you cookbook ,in the book you said there are few ways to do this.As we know,we can usd osg::Drawable callback,and you also said we can use setUpViewInWIndow method and get graphicContex ,actually i tried use the third way .but it not work at all! can you help me do this.i really don't know how to solve this problem.
Look forward your message
thanks.
Hi @xarray ,
We're attempting to use your excellent EffectCompositor snippet in OpenMW, but run into an issue trying to chain multiple effects together. I couldn't find any example of how to this (or if it's even supported), and my naive attempt of creating a hierarchy of effect nodes didn't work (only the last effect renders). Is this supposed to work or are we missing a feature? Any idea on how this would best be achieved? Here are some more details on what I tried: https://forum.openmw.org/viewtopic.php?f=6&t=4425&sid=c723cd8f0daf76d23e76dc14906a83e8#p48178
Another idea would be to write some code to "merge" two compositor definitions into one, but that doesn't seem trivial.
Thanks!
Hi @xarray ,
Just cloned the repo and noticed that test.xml for osgeffectscompositor.cpp is not present.
https://github.com/xarray/osgRecipes/blob/master/effectcompositor/osgeffectcompositor.cpp#L140
Am I missing something?
Also CMake is not looking in the correct places for finding OSG in 64 linux distributions. I will send a pull request about that.
Thanks!
First of all, great work!
I want to integrate Spark particle. However, the link related ( http://spark.developpez.com/ ) doesn't work. I have downloaded version 1.5.5 from http://sourceforge.net/projects/sparkengine/ , but it has link errors. I am using Visual Studio 2010. I tried with 2008 libraries, and recompiling with VS2010, but no success.
How can I integrate it with OSG? Thanks!
Hi Rui,
I tried to make the effectcompositor work by running those examples (colorgrading.xml, ssao.xml, etc.) However, when I enabled both --shadowed argument and (pe)ssao.xml, the scene just freezed in the first frame, without producing useful debugging information.
I just used the default file osgeffectcompositor.cpp to run the examples without changing any other settings. I tried on both GTX580 and intel HD4400 (with both windows 8.1 and mac os 10 on HD4400) with osg 3.2.1 and 3.2.2 release build. Both of them exposed the same issue.
Linking osg::Program "SSAO_Combining" id=7 contextID=0
Uniform "sceneTex" loc=0 size=1 type=sampler2D
Uniform "viewportHeight" loc=1 size=1 type=float
Uniform "aoTex" loc=2 size=1 type=sampler2D
Uniform "viewportWidth" loc=3 size=1 type=float
Attrib "gl_Vertex" loc=0 size=1
Attrib "gl_MultiTexCoord0" loc=1 size=1
Setting up osg::Camera::FRAME_BUFFER
Created new 0x1022c4dd0 TextureObject, _numOfTextureObjects 1
glGetString(GL_RENDERER)==Intel HD Graphics 4400 OpenGL Engine
end draw() 0x102217280
draw() 0x102217280
The debugging info just stops here. The osgviewer is freezed but not crashed. But it is not responding to any events, like ESC.
Note that if I run the program without --shadowed, the ssao works fine.
Thank you for your time.
Robin
Hello.
I try to use AntTweakBar along with Opengl core.
So i call TwInit( TW_OPENGL_CORE, NULL );
The problem is that i get some errors:
Cannot load function glBlendColor
Cannot load function glBlendEquation
and many more core functions.
I had to use the following:
fprintf(stderr, "AntTweakBar: Cannot load function %s\n", g_OGLCoreFuncRec[i].m_Name);
in function: int LoadOpenGLCore()
What can i do for AntTweakBar to see these functions ?
Thank you for your time.
You switched out two parameters the wrong way.
PHYSFS_read( handle, &(buffer[0]), filesize, 1 );
should be 1, filesize
(no joke)
Other than that, the code was outstanding, small and effective. This vfs tutorial that also uses physfs is too long and complicated. Yours is succinct and near perfect.
Hello. Thank you very much for your previous answers.
I closed by mistake the previous thread.
So if i create a Drawble, which calls TwDraw() and add this drawable (using a geometry) to the scene graph, will it be ok ?
Do i have to create manually the shaders which will render the tweak bar ?
Or does the TwDraw() takes care of it manually ?
thnx.
are you try If you input an orthographic projection, i can't find some way to solve it.
In NurbsSurface
and CloudBlock
, the function computeBound
is redefined. But with the current OSG's master brach, the build process ends in an error:
error: invalid covariant return type for 'virtual osg::BoundingBox NurbsSurface::computeBound() const'
error: overriding 'virtual osg::BoundingSphere osg::Drawable::computeBound() cost'
It seems that now Drawable
has two functions for computing the bounds. The old computeBound
now returns a BoundingSphere
, whereas the one returning a BoundingBox
is now named computeBoundingBox
. Even though master isn't a stable release, I think the changes will remain for future releases.
Modifying the source code for NurbsSurface and changing computeBound
to computeBoundingBox
let me continue with the build.
I can make a pull request with the changes if you want. :)
Hello,I'm trying to embed OSG into web browsers according to the cookbook,and I can register the plugin successfully,but the browser(IE ,FireFox) always breaks down .Anybody can help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.