FadeText 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 OSGTEXT_FADETEXT
  14. #define OSGTEXT_FADETEXT 1
  15. #include <osgText/Text>
  16. namespace osgText {
  17. class OSGTEXT_EXPORT FadeText : public osgText::Text
  18. {
  19. public:
  20. FadeText();
  21. FadeText(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  22. META_Object(osgText,FadeText)
  23. /** Set the speed that the alpha value changes as the text is occluded or becomes visible.*/
  24. void setFadeSpeed(float fadeSpeed) { _fadeSpeed = fadeSpeed; }
  25. /** Get the speed that the alpha value changes.*/
  26. float getFadeSpeed() const { return _fadeSpeed; }
  27. /** Draw the text.*/
  28. virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
  29. protected:
  30. virtual ~FadeText() {}
  31. void init();
  32. struct FadeTextUpdateCallback;
  33. friend struct FadeTextUpdateCallback;
  34. typedef std::map<osg::View*, osg::Vec4 > ViewBlendColourMap;
  35. ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; }
  36. const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; }
  37. float _fadeSpeed;
  38. mutable ViewBlendColourMap _viewBlendColourMap;
  39. };
  40. }
  41. #endif