From b23a48a763572b00b5eb547ccb05e75b4ada72e1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 19 Aug 2002 11:42:37 +0000 Subject: [PATCH] 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. --- VisualStudio/osg/osg.dsp | 6 ++- VisualStudio/osgPlugins/osg/dot_osg.dsp | 2 +- include/osg/EarthSky | 49 ++----------------- include/osg/NodeVisitor | 4 +- include/osg/Transparency | 1 + include/osgUtil/CullVisitor | 10 ++-- src/Demos/osghangglide/osghangglide.cpp | 10 ++-- src/osg/{EarthSky.cpp => ClearNode.cpp} | 6 +-- src/osg/Makefile | 2 +- src/osgPlugins/dx/DXWriter.cpp | 14 +++--- src/osgPlugins/osg/BlendFunc.cpp | 17 ++++--- .../osg/{EarthSky.cpp => ClearNode.cpp} | 30 ++++++++---- src/osgPlugins/osg/Makefile | 2 +- src/osgUtil/CullVisitor.cpp | 4 +- src/osgUtil/SceneView.cpp | 10 ++-- 15 files changed, 71 insertions(+), 96 deletions(-) rename src/osg/{EarthSky.cpp => ClearNode.cpp} (77%) rename src/osgPlugins/osg/{EarthSky.cpp => ClearNode.cpp} (67%) diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index 08bda5faa..0605025b4 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -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 diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index f13b521cb..4b9c2483a 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -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 diff --git a/include/osg/EarthSky b/include/osg/EarthSky index 6696d71d7..17e3e354b 100644 --- a/include/osg/EarthSky +++ b/include/osg/EarthSky @@ -5,54 +5,13 @@ #ifndef OSG_EARTHSKY #define OSG_EARTHSKY 1 -#include -#include +#include 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 } diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index e810eec3d..842b8b791 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -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); } diff --git a/include/osg/Transparency b/include/osg/Transparency index 8ed610da1..e9fd1c732 100644 --- a/include/osg/Transparency +++ b/include/osg/Transparency @@ -12,6 +12,7 @@ namespace osg { #ifdef USE_DEPRECATED_API typedef BlendFunc Transparency; #endif + } #endif diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 11bc3c4fc..19fea7a2b 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -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 _earthSky; + osg::ref_ptr _clearNode; TransparencySortMode _tsm; diff --git a/src/Demos/osghangglide/osghangglide.cpp b/src/Demos/osghangglide/osghangglide.cpp index 7e19f8f36..33d864093 100644 --- a/src/Demos/osghangglide/osghangglide.cpp +++ b/src/Demos/osghangglide/osghangglide.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -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) diff --git a/src/osg/EarthSky.cpp b/src/osg/ClearNode.cpp similarity index 77% rename from src/osg/EarthSky.cpp rename to src/osg/ClearNode.cpp index 79275af77..979b3681e 100644 --- a/src/osg/EarthSky.cpp +++ b/src/osg/ClearNode.cpp @@ -1,13 +1,13 @@ -#include +#include #include using namespace osg; /** - * EarthSky constructor. + * ClearNode constructor. */ -EarthSky::EarthSky() +ClearNode::ClearNode() { StateSet* stateset = osgNew StateSet; stateset->setRenderBinDetails(-1,"RenderBin"); diff --git a/src/osg/Makefile b/src/osg/Makefile index fb65335f2..ffe5fa437 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -26,7 +26,7 @@ CXXFILES =\ DOFTransform.cpp\ Drawable.cpp\ DrawPixels.cpp\ - EarthSky.cpp\ + ClearNode.cpp\ Fog.cpp\ FrameStamp.cpp\ FrontFace.cpp\ diff --git a/src/osgPlugins/dx/DXWriter.cpp b/src/osgPlugins/dx/DXWriter.cpp index 5eb95676a..0ec6a2067 100644 --- a/src/osgPlugins/dx/DXWriter.cpp +++ b/src/osgPlugins/dx/DXWriter.cpp @@ -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; } diff --git a/src/osgPlugins/osg/BlendFunc.cpp b/src/osgPlugins/osg/BlendFunc.cpp index 5478ed847..c9b7736dd 100644 --- a/src/osgPlugins/osg/BlendFunc.cpp +++ b/src/osgPlugins/osg/BlendFunc.cpp @@ -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; diff --git a/src/osgPlugins/osg/EarthSky.cpp b/src/osgPlugins/osg/ClearNode.cpp similarity index 67% rename from src/osgPlugins/osg/EarthSky.cpp rename to src/osgPlugins/osg/ClearNode.cpp index 0a572a416..d62db2d3e 100644 --- a/src/osgPlugins/osg/EarthSky.cpp +++ b/src/osgPlugins/osg/ClearNode.cpp @@ -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(obj); + ClearNode& es = static_cast(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(obj); + const ClearNode& es = static_cast(obj); fw.indent() << "requiresClear "; if (es.getRequiresClear()) diff --git a/src/osgPlugins/osg/Makefile b/src/osgPlugins/osg/Makefile index ac2988cee..1afaf7556 100644 --- a/src/osgPlugins/osg/Makefile +++ b/src/osgPlugins/osg/Makefile @@ -12,7 +12,7 @@ CXXFILES =\ Depth.cpp\ DOFTransform.cpp\ Drawable.cpp\ - EarthSky.cpp\ + ClearNode.cpp\ Fog.cpp\ FrontFace.cpp\ Geode.cpp\ diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index f712f97f2..13c3c0667 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -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(); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 20e682b7b..cbae059ac 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -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..