From cfac4c74bc5bbc95dc7f04d838c39f46916f86f8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 15 Jul 2005 08:32:36 +0000 Subject: [PATCH] Added reference frame to TexGenNode --- include/osg/TexGenNode | 16 ++++++++++++++++ src/osgUtil/CullVisitor.cpp | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/osg/TexGenNode b/include/osg/TexGenNode index 9f6ecbb69..a6ebaf1f4 100644 --- a/include/osg/TexGenNode +++ b/include/osg/TexGenNode @@ -33,6 +33,20 @@ class OSG_EXPORT TexGenNode : public Group META_Node(osg, TexGenNode); + enum ReferenceFrame + { + RELATIVE_RF, + ABSOLUTE_RF + }; + + /** Set the TexGenNode's ReferenceFrame, either to be relative to its + * parent reference frame. */ + void setReferenceFrame(ReferenceFrame rf); + + /** Ge thte TexGenNode's ReferenceFrame.*/ + ReferenceFrame getReferenceFrame() const { return _referenceFrame; } + + /** Set the texture unit that this TexGenNode is associated with.*/ void setTextureUnit(unsigned int textureUnit) { _textureUnit = textureUnit; } unsigned int getTextureUnit() const { return _textureUnit; } @@ -54,6 +68,8 @@ class OSG_EXPORT TexGenNode : public Group unsigned int _textureUnit; StateAttribute::GLModeValue _value; osg::ref_ptr _texgen; + + ReferenceFrame _referenceFrame; }; } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index ae069f40d..247b678e6 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -873,10 +873,17 @@ void CullVisitor::apply(TexGenNode& node) StateSet* node_state = node.getStateSet(); if (node_state) pushStateSet(node_state); - RefMatrix& matrix = getModelViewMatrix(); - - addPositionedTextureAttribute(node.getTextureUnit(), &matrix,node.getTexGen()); + if (node.getReferenceFrame()==osg::TexGenNode::RELATIVE_RF) + { + RefMatrix& matrix = getModelViewMatrix(); + addPositionedTextureAttribute(node.getTextureUnit(), &matrix ,node.getTexGen()); + } + else + { + addPositionedTextureAttribute(node.getTextureUnit(), 0 ,node.getTexGen()); + } + handle_cull_callbacks_and_traverse(node); // pop the node's state off the geostate stack. @@ -1028,6 +1035,7 @@ void CullVisitor::apply(osg::CameraNode& camera) // push the node's state. StateSet* node_state = camera.getStateSet(); if (node_state) pushStateSet(node_state); + if (camera.getReferenceFrame()==osg::Transform::ABSOLUTE_RF) { @@ -1080,7 +1088,7 @@ void CullVisitor::apply(osg::CameraNode& camera) rtts->setViewport( viewport ); // set up to charge the same RenderStageLighting is the parent previous stage. - rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); + //rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); // record the render bin, to be restored after creation // of the render to text