dded osg::ClipNode class for managing OpenGL clipping planes, and osgclip demo.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <osg/LOD>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/ClipNode>
|
||||
#include <osg/Notify>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/AlphaFunc>
|
||||
@@ -60,6 +61,7 @@ class PrintVisitor : public NodeVisitor
|
||||
virtual void apply(Geode& node) { apply((Node&)node); }
|
||||
virtual void apply(Billboard& node) { apply((Geode&)node); }
|
||||
virtual void apply(LightSource& node) { apply((Node&)node); }
|
||||
virtual void apply(ClipNode& node) { apply((Node&)node); }
|
||||
|
||||
virtual void apply(Group& node) { apply((Node&)node); }
|
||||
virtual void apply(Transform& node) { apply((Group&)node); }
|
||||
@@ -524,13 +526,34 @@ void CullVisitor::apply(LightSource& node)
|
||||
Light* light = node.getLight();
|
||||
if (light)
|
||||
{
|
||||
addLight(light,&matrix);
|
||||
addPositionedAttribute(&matrix,light);
|
||||
}
|
||||
|
||||
// pop the node's state off the geostate stack.
|
||||
if (node_state) popStateSet();
|
||||
}
|
||||
|
||||
void CullVisitor::apply(ClipNode& node)
|
||||
{
|
||||
// push the node's state.
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
Matrix& matrix = getModelViewMatrix();
|
||||
|
||||
const ClipNode::ClipPlaneList& planes = node.getClipPlaneList();
|
||||
for(ClipNode::ClipPlaneList::const_iterator itr=planes.begin();
|
||||
itr!=planes.end();
|
||||
++itr)
|
||||
{
|
||||
addPositionedAttribute(&matrix,itr->get());
|
||||
}
|
||||
|
||||
handle_cull_callbacks_and_traverse(node);
|
||||
|
||||
// pop the node's state off the geostate stack.
|
||||
if (node_state) popStateSet();
|
||||
}
|
||||
|
||||
void CullVisitor::apply(Group& node)
|
||||
{
|
||||
@@ -824,7 +847,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
|
||||
if (!bs.isValid())
|
||||
{
|
||||
std::cout << "bb invalid"<<&node<<std::endl;
|
||||
osg::notify(osg::WARN) << "bb invalid"<<&node<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,11 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
|
||||
// Statistics features
|
||||
bool RenderStage::getStats(Statistics* primStats)
|
||||
{
|
||||
if (_renderStageLighting.valid()) primStats->addLight(_renderStageLighting->_lightList.size());
|
||||
if (_renderStageLighting.valid())
|
||||
{
|
||||
// need to re-implement by checking for lights in the scene
|
||||
// by downcasting the positioned attribute list. RO. May 2002.
|
||||
//primStats->addLight(_renderStageLighting->_lightList.size());
|
||||
}
|
||||
return RenderBin::getStats(primStats);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ RenderStageLighting::~RenderStageLighting()
|
||||
|
||||
void RenderStageLighting::reset()
|
||||
{
|
||||
_lightList.clear();
|
||||
_attrList.clear();
|
||||
}
|
||||
|
||||
void RenderStageLighting::draw(osg::State& state,RenderLeaf*& previous)
|
||||
@@ -30,8 +30,8 @@ void RenderStageLighting::draw(osg::State& state,RenderLeaf*& previous)
|
||||
}
|
||||
|
||||
// apply the light list.
|
||||
for(LightList::iterator litr=_lightList.begin();
|
||||
litr!=_lightList.end();
|
||||
for(AttrMatrixList::iterator litr=_attrList.begin();
|
||||
litr!=_attrList.end();
|
||||
++litr)
|
||||
{
|
||||
state.applyModelViewMatrix((*litr).second.get());
|
||||
|
||||
@@ -325,10 +325,10 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil
|
||||
switch(_lightingMode)
|
||||
{
|
||||
case(HEADLIGHT):
|
||||
renderStage->addLight(_light.get(),NULL);
|
||||
renderStage->addPositionedAttribute(NULL,_light.get());
|
||||
break;
|
||||
case(SKY_LIGHT):
|
||||
renderStage->addLight(_light.get(),modelview);
|
||||
renderStage->addPositionedAttribute(modelview,_light.get());
|
||||
break;
|
||||
case(NO_SCENEVIEW_LIGHT):
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user