PositionalStateContainer 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGUTIL_POSITIONALSTATECONTAINER
  14. #define OSGUTIL_POSITIONALSTATECONTAINER 1
  15. #include <osg/Object>
  16. #include <osg/Light>
  17. #include <osg/State>
  18. #include <osgUtil/RenderLeaf>
  19. #include <osgUtil/StateGraph>
  20. namespace osgUtil {
  21. /**
  22. * PositionalStateContainer base class. Used in RenderStage class.
  23. */
  24. class OSGUTIL_EXPORT PositionalStateContainer : public osg::Object
  25. {
  26. public:
  27. PositionalStateContainer();
  28. virtual osg::Object* cloneType() const { return new PositionalStateContainer(); }
  29. virtual osg::Object* clone(const osg::CopyOp&) const { return new PositionalStateContainer(); } // note only implements a clone of type.
  30. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const PositionalStateContainer*>(obj)!=0L; }
  31. virtual const char* libraryName() const { return "osgUtil"; }
  32. virtual const char* className() const { return "PositionalStateContainer"; }
  33. virtual void reset();
  34. typedef std::pair< osg::ref_ptr<const osg::StateAttribute> , osg::ref_ptr<osg::RefMatrix> > AttrMatrixPair;
  35. typedef std::vector< AttrMatrixPair > AttrMatrixList;
  36. typedef std::map< unsigned int, AttrMatrixList > TexUnitAttrMatrixListMap;
  37. AttrMatrixList& getAttrMatrixList() { return _attrList; }
  38. virtual void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
  39. {
  40. _attrList.push_back(AttrMatrixPair(attr,matrix));
  41. }
  42. TexUnitAttrMatrixListMap& getTexUnitAttrMatrixListMap() { return _texAttrListMap; }
  43. virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr)
  44. {
  45. _texAttrListMap[textureUnit].push_back(AttrMatrixPair(attr,matrix));
  46. }
  47. virtual void draw(osg::State& state,RenderLeaf*& previous, const osg::Matrix* postMultMatrix = 0);
  48. public:
  49. AttrMatrixList _attrList;
  50. TexUnitAttrMatrixListMap _texAttrListMap;
  51. protected:
  52. virtual ~PositionalStateContainer();
  53. };
  54. }
  55. #endif