openscenegraph
FadeText
Go to the documentation of this file.
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
14#ifndef OSGTEXT_FADETEXT
15#define OSGTEXT_FADETEXT 1
16
17#include <osgText/Text>
18
19namespace osgText {
20
21
22class OSGTEXT_EXPORT FadeText : public osgText::Text
23{
24public:
25
26 FadeText();
27 FadeText(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
28
29 META_Object(osgText,FadeText)
30
31
32 /** Set the speed that the alpha value changes as the text is occluded or becomes visible.*/
33 void setFadeSpeed(float fadeSpeed) { _fadeSpeed = fadeSpeed; }
34
35 /** Get the speed that the alpha value changes.*/
36 float getFadeSpeed() const { return _fadeSpeed; }
37
38 /** Draw the text.*/
39 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
40
41protected:
42
43 virtual ~FadeText() {}
44
45 void init();
46
47 struct FadeTextUpdateCallback;
48 friend struct FadeTextUpdateCallback;
49
50 typedef std::map<osg::View*, osg::Vec4 > ViewBlendColourMap;
51
52 ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; }
53 const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; }
54
55 float _fadeSpeed;
56
57 mutable ViewBlendColourMap _viewBlendColourMap;
58};
59
60}
61
62
63#endif