Renamed the osg::EarthSky to osg::ClearNode to make it more obvious what

role it has play and make it more relevant to non vis-sim applications.
This commit is contained in:
Robert Osfield 2002-08-19 11:42:37 +00:00
parent c72953d94b
commit b23a48a763
15 changed files with 71 additions and 96 deletions

View File

@ -185,7 +185,7 @@ SOURCE=..\..\src\osg\DrawPixels.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\EarthSky.cpp
SOURCE=..\..\src\osg\ClearNode.cpp
# End Source File
# Begin Source File
@ -501,6 +501,10 @@ SOURCE=..\..\Include\Osg\DrawPixels
# End Source File
# Begin Source File
SOURCE=..\..\include\osg\ClearNode
# End Source File
# Begin Source File
SOURCE=..\..\include\osg\EarthSky
# End Source File
# Begin Source File

View File

@ -134,7 +134,7 @@ SOURCE=..\..\..\src\osgPlugins\osg\DOFTransform.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\EarthSky.cpp
SOURCE=..\..\..\src\osgPlugins\osg\ClearNode.cpp
# End Source File
# Begin Source File

View File

@ -5,54 +5,13 @@
#ifndef OSG_EARTHSKY
#define OSG_EARTHSKY 1
#include <osg/Group>
#include <osg/Vec4>
#include <osg/ClearNode>
namespace osg {
/** EarthSky is a Group node which controls the clearing of the color and depth
* buffers at the start of each frame.
* The earth sky by default is empty and simply holds the clear color of
* the background. However, if the uses wants to add their own clearing of
* the color and depth buffers then the children can be added, and the
* background clear turned off. The EarthSky by default has StateSet attached
* to it which sets the default EarthSky bin number to -1, so that all drawables
* below it are placed in a separate bin from the rest of the scene graph, and
* are rendered prior to standard opaque and transparent drawables.
*/
class SG_EXPORT EarthSky : public Group
{
public :
EarthSky();
EarthSky(const EarthSky& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Group(es,copyop),
_requiresClear(es._requiresClear),
_clearColor(es._clearColor) {}
META_Node(osg, EarthSky);
/** Sets the flag which control whether a glClear is required at the beginning of each frame. */
inline void setRequiresClear(const bool requiresClear) { _requiresClear = requiresClear; }
/** Gets the flag which control whether a glClear is required at the beginning of each frame. */
inline const bool getRequiresClear() const { return _requiresClear; }
/** Sets the clear color. */
inline void setClearColor(const Vec4& color) { _clearColor = color; }
/** Returns the clear color. */
inline const Vec4& getClearColor() const { return _clearColor; }
protected :
virtual ~EarthSky() {}
bool _requiresClear;
Vec4 _clearColor;
};
#ifdef USE_DEPRECATED_API
typedef ClearNode EarthSky;
#endif
}

View File

@ -24,7 +24,7 @@ class Projection;
class LOD;
class Switch;
class Impostor;
class EarthSky;
class ClearNode;
class OccluderNode;
class Sequence;
@ -210,7 +210,7 @@ class SG_EXPORT NodeVisitor : public Referenced
virtual void apply(Sequence& node) { apply((Switch&)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); }
virtual void apply(ClearNode& node) { apply((Group&)node); }
virtual void apply(OccluderNode& node) { apply((Group&)node); }

View File

@ -12,6 +12,7 @@ namespace osg {
#ifdef USE_DEPRECATED_API
typedef BlendFunc Transparency;
#endif
}
#endif

View File

@ -13,7 +13,7 @@
#include <osg/StateSet>
#include <osg/State>
#include <osg/Impostor>
#include <osg/EarthSky>
#include <osg/ClearNode>
#include <osg/Notify>
#include <osg/Notify>
@ -59,12 +59,12 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
virtual void apply(osg::Projection& node);
virtual void apply(osg::Switch& node);
virtual void apply(osg::LOD& node);
virtual void apply(osg::EarthSky& node);
virtual void apply(osg::ClearNode& node);
virtual void apply(osg::OccluderNode& node);
virtual void apply(osg::Impostor& node);
void setEarthSky(const osg::EarthSky* earthSky) { _earthSky = earthSky; }
const osg::EarthSky* getEarthSky() const { return _earthSky.get(); }
void setClearNode(const osg::ClearNode* earthSky) { _clearNode = earthSky; }
const osg::ClearNode* getClearNode() const { return _clearNode.get(); }
/** Switch the creation of Impostors on or off.
@ -243,7 +243,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
float _computed_znear;
float _computed_zfar;
osg::ref_ptr<const osg::EarthSky> _earthSky;
osg::ref_ptr<const osg::ClearNode> _clearNode;
TransparencySortMode _tsm;

View File

@ -2,7 +2,7 @@
#include <osg/Notify>
#include <osg/Depth>
#include <osg/StateSet>
#include <osg/EarthSky>
#include <osg/ClearNode>
#include <osg/Transform>
#include <osgUtil/CullVisitor>
@ -86,8 +86,8 @@ 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.
osg::EarthSky* earthSky = osgNew osg::EarthSky;
earthSky->setRequiresClear(false); // we've got base and sky to do it.
osg::ClearNode* clearNode = osgNew osg::ClearNode;
clearNode->setRequiresClear(false); // we've got base and sky to do it.
// use a transform to make the sky and base around with the eye point.
osg::Transform* transform = osgNew osg::Transform;
@ -108,10 +108,10 @@ int main( int argc, char **argv )
transform->addChild(makeBase()); // bin number -1 so draw second.
// add the transform to the earth sky.
earthSky->addChild(transform);
clearNode->addChild(transform);
// add to earth sky to the scene.
group->addChild(earthSky);
group->addChild(clearNode);
// the rest of the scene drawn after the base and sky above.
group->addChild(makeTrees()); // will drop into a transparent, depth sorted bin (1)

View File

@ -1,13 +1,13 @@
#include <osg/EarthSky>
#include <osg/ClearNode>
#include <algorithm>
using namespace osg;
/**
* EarthSky constructor.
* ClearNode constructor.
*/
EarthSky::EarthSky()
ClearNode::ClearNode()
{
StateSet* stateset = osgNew StateSet;
stateset->setRenderBinDetails(-1,"RenderBin");

View File

@ -26,7 +26,7 @@ CXXFILES =\
DOFTransform.cpp\
Drawable.cpp\
DrawPixels.cpp\
EarthSky.cpp\
ClearNode.cpp\
Fog.cpp\
FrameStamp.cpp\
FrontFace.cpp\

View File

@ -36,7 +36,7 @@
// UNSUPPORTED:
//
// - OSG Scene Graph Node Types:
// LightSource, Transform, Imposter, EarthSky,
// LightSource, Transform, Imposter, ClearNode,
// Switch - only active child written
// LOD - only most detailed child written
// Billboard - only static translation transform parenting child written,
@ -2404,7 +2404,7 @@ class StateSetActionVisitor : public osg::NodeVisitor
void apply(osg::Switch& node) { NodeVisitor::apply(node); }
void apply(osg::LOD& node) { NodeVisitor::apply(node); }
void apply(osg::Impostor& node) { NodeVisitor::apply(node); }
void apply(osg::EarthSky& node) { NodeVisitor::apply(node); }
void apply(osg::ClearNode& node) { NodeVisitor::apply(node); }
const osg::StateSet &GetActiveStateSet()
@ -2488,7 +2488,7 @@ class DXWriteVisitor : public StateSetActionVisitor
MessageBin &msg_bin;
enum NodeTypes { LOD, BILLBOARD, LIGHTSOURCE, TRANSFORM, SWITCH,
IMPOSTER, EARTHSKY };
IMPOSTER, CLEARNODE };
typedef std::map< NodeTypes, int > StringMap;
StringMap problem_nodes;
@ -2612,8 +2612,8 @@ class DXWriteVisitor : public StateSetActionVisitor
{ problem_nodes[ TRANSFORM ]++; apply((osg::Group&)node); }
void apply(osg::Impostor& node)
{ problem_nodes[ IMPOSTER ]++; apply((osg::LOD&)node); }
void apply(osg::EarthSky& node)
{ problem_nodes[ EARTHSKY ]++; apply((osg::Group&)node); }
void apply(osg::ClearNode& node)
{ problem_nodes[ CLEARNODE ]++; apply((osg::Group&)node); }
void ReportProblems();
};
@ -2652,8 +2652,8 @@ void DXWriteVisitor::ReportProblems()
msg_bin.Add( "WARNING: %d Imposter(s) found ... Skipped.\n",
smitr->second );
break;
case EARTHSKY :
msg_bin.Add( "WARNING: %d EarthSky(s) found ... Skipped.\n",
case CLEARNODE :
msg_bin.Add( "WARNING: %d ClearNode(s) found ... Skipped.\n",
smitr->second );
break;
}

View File

@ -15,14 +15,6 @@ bool BlendFunc_matchModeStr(const char* str,int& mode);
const char* BlendFunc_getModeStr(int value);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_BlendFuncProxy
(
osgNew osg::BlendFunc,
"BlendFunc",
"Object StateAttribute BlendFunc",
&BlendFunc_readLocalData,
&BlendFunc_writeLocalData
);
RegisterDotOsgWrapperProxy g_TransparencyProxy
(
@ -33,6 +25,15 @@ RegisterDotOsgWrapperProxy g_TransparencyProxy
&BlendFunc_writeLocalData
);
RegisterDotOsgWrapperProxy g_BlendFuncProxy
(
osgNew osg::BlendFunc,
"BlendFunc",
"Object StateAttribute BlendFunc",
&BlendFunc_readLocalData,
&BlendFunc_writeLocalData
);
bool BlendFunc_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;

View File

@ -1,4 +1,4 @@
#include "osg/EarthSky"
#include "osg/ClearNode"
#include "osgDB/Registry"
#include "osgDB/Input"
@ -8,24 +8,34 @@ using namespace osg;
using namespace osgDB;
// forward declare functions to use later.
bool EarthSky_readLocalData(Object& obj, Input& fr);
bool EarthSky_writeLocalData(const Object& obj, Output& fw);
bool ClearNode_readLocalData(Object& obj, Input& fr);
bool ClearNode_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_EarthSkyProxy
(
osgNew osg::EarthSky,
osgNew osg::ClearNode,
"EarthSky",
"Object Node EarthSky Group",
&EarthSky_readLocalData,
&EarthSky_writeLocalData
&ClearNode_readLocalData,
&ClearNode_writeLocalData
);
bool EarthSky_readLocalData(Object& obj, Input& fr)
RegisterDotOsgWrapperProxy g_ClearNodeProxy
(
osgNew osg::ClearNode,
"ClearNode",
"Object Node ClearNode Group",
&ClearNode_readLocalData,
&ClearNode_writeLocalData
);
bool ClearNode_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
EarthSky& es = static_cast<EarthSky&>(obj);
ClearNode& es = static_cast<ClearNode&>(obj);
if (fr.matchSequence("requiresClear"))
{
@ -60,9 +70,9 @@ bool EarthSky_readLocalData(Object& obj, Input& fr)
}
bool EarthSky_writeLocalData(const Object& obj, Output& fw)
bool ClearNode_writeLocalData(const Object& obj, Output& fw)
{
const EarthSky& es = static_cast<const EarthSky&>(obj);
const ClearNode& es = static_cast<const ClearNode&>(obj);
fw.indent() << "requiresClear ";
if (es.getRequiresClear())

View File

@ -12,7 +12,7 @@ CXXFILES =\
Depth.cpp\
DOFTransform.cpp\
Drawable.cpp\
EarthSky.cpp\
ClearNode.cpp\
Fog.cpp\
FrontFace.cpp\
Geode.cpp\

View File

@ -521,10 +521,10 @@ void CullVisitor::apply(LOD& node)
popCurrentMask();
}
void CullVisitor::apply(osg::EarthSky& node)
void CullVisitor::apply(osg::ClearNode& node)
{
// simply override the current earth sky.
setEarthSky(&node);
setClearNode(&node);
// push the node's state.
StateSet* node_state = node.getStateSet();

View File

@ -371,7 +371,7 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil
cullVisitor->setLODBias(_LODBias);
cullVisitor->setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize);
cullVisitor->setEarthSky(NULL); // reset earth sky on each frame.
cullVisitor->setClearNode(NULL); // reset earth sky on each frame.
cullVisitor->setRenderGraph(rendergraph);
cullVisitor->setRenderStage(renderStage);
@ -424,12 +424,12 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil
if (_globalState.valid()) cullVisitor->popStateSet();
const osg::EarthSky* earthSky = cullVisitor->getEarthSky();
if (earthSky)
const osg::ClearNode* clearNode = cullVisitor->getClearNode();
if (clearNode)
{
if (earthSky->getRequiresClear())
if (clearNode->getRequiresClear())
{
renderStage->setClearColor(earthSky->getClearColor());
renderStage->setClearColor(clearNode->getClearColor());
renderStage->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// really should set clear mask here, but what to? Need
// to consider the stencil and accumulation buffers..