MultiTextureControl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 OSGFX_MULTITEXTURECONTROL
  14. #define OSGFX_MULTITEXTURECONTROL
  15. #include <osg/Group>
  16. #include <osgFX/Export>
  17. namespace osgFX
  18. {
  19. /**
  20. This node provides control over the which texture units are active and the
  21. blending weighting between them.
  22. */
  23. class OSGFX_EXPORT MultiTextureControl: public osg::Group {
  24. public:
  25. MultiTextureControl();
  26. MultiTextureControl(const MultiTextureControl& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  27. META_Node(osgFX, MultiTextureControl);
  28. typedef osg::FloatArray TextureWeights;
  29. void setTextureWeights(TextureWeights* twl) { _textureWeights = twl; }
  30. TextureWeights* getTextureWeights() { return _textureWeights.get(); }
  31. const TextureWeights* getTextureWeights() const { return _textureWeights.get(); }
  32. void setTextureWeight(unsigned int unit, float weight);
  33. float getTextureWeight(unsigned int unit) const { return (unit<_textureWeights->size()) ? (*_textureWeights)[unit] : 0.0f; }
  34. unsigned int getNumTextureWeights() const { return _textureWeights->size(); }
  35. void setUseTexEnvCombine(bool flag) { _useTexEnvCombine = flag; }
  36. bool getUseTexEnvCombine() const { return _useTexEnvCombine; }
  37. void setUseTextureWeightsUniform(bool flag) { _useTextureWeightsUniform = flag; }
  38. bool getUseTextureWeightsUniform() const { return _useTextureWeightsUniform; }
  39. protected:
  40. virtual ~MultiTextureControl() {}
  41. MultiTextureControl& operator = (const MultiTextureControl&) { return *this; }
  42. void updateStateSet();
  43. osg::ref_ptr<TextureWeights> _textureWeights;
  44. bool _useTexEnvCombine;
  45. bool _useTextureWeightsUniform;
  46. };
  47. }
  48. #endif