Added osg::EarthSky node to the core osg library, and added support for it into
osgUtil::SceneView, osg::CullVisitor, osgPlugin/osg and updated the hangglide demo to use the new earth sky node.
This commit is contained in:
parent
fc1fa57275
commit
430c8606e9
@ -134,6 +134,10 @@ SOURCE=..\..\src\osg\Drawable.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\EarthSky.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\Fog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -334,6 +338,10 @@ SOURCE=..\..\Include\Osg\Drawable
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\EarthSky
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -15,6 +15,7 @@ class LOD;
|
||||
class Sequence;
|
||||
class Switch;
|
||||
class Impostor;
|
||||
class EarthSky;
|
||||
|
||||
/** Visitor for type safe operations on osg::Node's.
|
||||
Based on GOF's Visitor pattern.*/
|
||||
@ -128,6 +129,7 @@ class SG_EXPORT NodeVisitor : public Referenced
|
||||
virtual void apply(Sequence& node) { apply((Group&)node); }
|
||||
virtual void apply(LOD& node) { apply((Group&)node); }
|
||||
virtual void apply(Impostor& node) { apply((LOD&)node); }
|
||||
virtual void apply(EarthSky& node) { apply((Group&)node); }
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <osg/State>
|
||||
#include <osg/Camera>
|
||||
#include <osg/Impostor>
|
||||
#include <osg/EarthSky>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgUtil/RenderGraph>
|
||||
@ -47,12 +48,19 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
virtual void apply(osg::Transform& node);
|
||||
virtual void apply(osg::Switch& node);
|
||||
virtual void apply(osg::LOD& node);
|
||||
virtual void apply(osg::EarthSky& node);
|
||||
virtual void apply(osg::Impostor& node);
|
||||
|
||||
void setCamera(const osg::Camera& camera);
|
||||
|
||||
|
||||
void setCamera(const osg::Camera& camera);
|
||||
const osg::Camera* getCamera() const { return _camera.get(); }
|
||||
|
||||
|
||||
void setEarthSky(const osg::EarthSky* earthSky) { _earthSky = earthSky; }
|
||||
const osg::EarthSky* getEarthSky() const { return _earthSky.get(); }
|
||||
|
||||
|
||||
void setLODBias(const float bias) { _LODBias = bias; }
|
||||
const float getLODBias() const { return _LODBias; }
|
||||
|
||||
@ -280,6 +288,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
|
||||
osg::ref_ptr<const osg::Camera> _camera;
|
||||
|
||||
osg::ref_ptr<const osg::EarthSky> _earthSky;
|
||||
|
||||
TransparencySortMode _tsm;
|
||||
|
||||
// viewport x,y,width,height respectively.
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <osg/Notify>
|
||||
#include <osg/Depth>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/EarthSky>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
@ -131,8 +132,12 @@ int main( int argc, char **argv )
|
||||
// osg::Depth, and setting their bin numbers to less than 0,
|
||||
// to force them to draw before the rest of the scene.
|
||||
|
||||
group->addChild(makeSky()); // bin number -2 so drawn first.
|
||||
group->addChild(makeBase()); // bin number -1 so draw second.
|
||||
osg::EarthSky* earthSky = new osg::EarthSky;
|
||||
earthSky->setRequiresClear(false); // we've got base and sky to do it.
|
||||
earthSky->addChild(makeSky()); // bin number -2 so drawn first.
|
||||
earthSky->addChild(makeBase()); // bin number -1 so draw second.
|
||||
|
||||
group->addChild(earthSky);
|
||||
|
||||
// the rest of the scene drawn after the base and sky above.
|
||||
group->addChild(makeTrees()); // will drop into a transparent, depth sorted bin (1)
|
||||
@ -158,10 +163,6 @@ int main( int argc, char **argv )
|
||||
|
||||
osgUtil::SceneView* sv = viewer.getViewportSceneView(0);
|
||||
|
||||
// switch off the render stages clear mask as we use the earth/sky
|
||||
// to clear it for us, see above.
|
||||
sv->getRenderStage()->setClearMask(0);
|
||||
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
|
@ -12,6 +12,7 @@ C++FILES = \
|
||||
CullFace.cpp\
|
||||
Depth.cpp \
|
||||
Drawable.cpp\
|
||||
EarthSky.cpp\
|
||||
Fog.cpp\
|
||||
FrameStamp.cpp\
|
||||
FrontFace.cpp\
|
||||
@ -69,6 +70,7 @@ TARGET_INCLUDE_FILES = \
|
||||
osg/CullFace\
|
||||
osg/Depth\
|
||||
osg/Drawable\
|
||||
osg/EarthSky\
|
||||
osg/Export\
|
||||
osg/Fog\
|
||||
osg/FrameStamp\
|
||||
|
@ -9,6 +9,7 @@ C++FILES = \
|
||||
CullFace.cpp\
|
||||
Depth.cpp\
|
||||
Drawable.cpp\
|
||||
EarthSky.cpp\
|
||||
Fog.cpp\
|
||||
FrontFace.cpp\
|
||||
Geode.cpp\
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <osg/LOD>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/Impostor>
|
||||
#include <osg/Notify>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/AlphaFunc>
|
||||
@ -645,6 +644,23 @@ void CullVisitor::apply(LOD& node)
|
||||
_cullingModeStack.pop_back();
|
||||
}
|
||||
|
||||
void CullVisitor::apply(osg::EarthSky& node)
|
||||
{
|
||||
// simply override the current earth sky.
|
||||
setEarthSky(&node);
|
||||
|
||||
// push the node's state.
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
traverse(node);
|
||||
|
||||
// pop the node's state off the render graph stack.
|
||||
if (node_state) popStateSet();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CullVisitor::apply(Impostor& node)
|
||||
{
|
||||
const BoundingSphere& bs = node.getBound();
|
||||
|
@ -135,6 +135,7 @@ void SceneView::cull()
|
||||
_cullVisitor->setLODBias(_lodBias);
|
||||
_cullVisitor->setCamera(*_camera);
|
||||
_cullVisitor->setViewport(_viewport.get());
|
||||
_cullVisitor->setEarthSky(NULL); // reset earth sky on each frame.
|
||||
|
||||
_renderStage->reset();
|
||||
|
||||
@ -170,6 +171,24 @@ void SceneView::cull()
|
||||
_renderStage->sort();
|
||||
|
||||
|
||||
const osg::EarthSky* earthSky = _cullVisitor->getEarthSky();
|
||||
if (earthSky)
|
||||
{
|
||||
if (earthSky->getRequiresClear())
|
||||
{
|
||||
_renderStage->setClearColor(earthSky->getClearColor());
|
||||
// really should set clear mask here, but what to? Need
|
||||
// to consider the stencil and accumulation buffers..
|
||||
// will defer to later. Robert Osfield. October 2001.
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have an earth sky implementation to do the work for use
|
||||
// so we don't need to clear.
|
||||
_renderStage->setClearMask(0);
|
||||
}
|
||||
}
|
||||
|
||||
// prune out any empty RenderGraph children.
|
||||
// note, this would be not required if the _renderGraph had been
|
||||
// reset at the start of each frame (see top of this method) but
|
||||
|
Loading…
Reference in New Issue
Block a user