From 3248f885ecbd3c98e0d27ccef74a9f5d0e0538f9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 8 Jul 2004 22:12:49 +0000 Subject: [PATCH] Replaced the custom MyTexGen class with a standard TexGen, and utilised the new RenderStage addPositionedTextureAtribute method. --- .../osgshadowtexture/CreateShadowedScene.cpp | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/examples/osgshadowtexture/CreateShadowedScene.cpp b/examples/osgshadowtexture/CreateShadowedScene.cpp index 2348ce97a..dbc832394 100644 --- a/examples/osgshadowtexture/CreateShadowedScene.cpp +++ b/examples/osgshadowtexture/CreateShadowedScene.cpp @@ -60,28 +60,6 @@ class CreateShadowTextureCullCallback : public osg::NodeCallback osg::ref_ptr _shadowState; osg::ref_ptr _shadowedState; - // we need this to get round the order dependance - // of eye linear tex gen... - class MyTexGen : public TexGen - { - public: - - void setMatrix(const osg::Matrix& matrix) - { - _matrix = matrix; - } - - virtual void apply(osg::State& state) const - { - glPushMatrix(); - glLoadMatrix(_matrix.ptr()); - TexGen::apply(state); - glPopMatrix(); - } - - osg::Matrix _matrix; - }; - }; void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::CullVisitor& cv) @@ -219,14 +197,17 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull // set up the stateset to decorate the shadower with the shadow texture // with the appropriate tex gen coords. - MyTexGen* texgen = new MyTexGen; - texgen->setMatrix(MV); + TexGen* texgen = new TexGen; + //texgen->setMatrix(MV); texgen->setMode(osg::TexGen::EYE_LINEAR); texgen->setPlane(osg::TexGen::S,osg::Plane(MVPT(0,0),MVPT(1,0),MVPT(2,0),MVPT(3,0))); texgen->setPlane(osg::TexGen::T,osg::Plane(MVPT(0,1),MVPT(1,1),MVPT(2,1),MVPT(3,1))); texgen->setPlane(osg::TexGen::R,osg::Plane(MVPT(0,2),MVPT(1,2),MVPT(2,2),MVPT(3,2))); texgen->setPlane(osg::TexGen::Q,osg::Plane(MVPT(0,3),MVPT(1,3),MVPT(2,3),MVPT(3,3))); + cv.getRenderStage()->addPositionedTextureAttribute(0,new osg::RefMatrix(MV),texgen); + + _shadowedState->setTextureAttributeAndModes(_unit,_texture.get(),osg::StateAttribute::ON); _shadowedState->setTextureAttribute(_unit,texgen); _shadowedState->setTextureMode(_unit,GL_TEXTURE_GEN_S,osg::StateAttribute::ON);