From 85dc696c0919eecfe63a0daac567fa391409a775 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 Oct 2006 09:06:28 +0000 Subject: [PATCH] Added FadeText::setFadeSpeed and made internal data structures protected. --- include/osgText/FadeText | 20 ++++++++++++++++---- src/osgText/FadeText.cpp | 5 +++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/osgText/FadeText b/include/osgText/FadeText index 128915a21..5eebfc8b6 100644 --- a/include/osgText/FadeText +++ b/include/osgText/FadeText @@ -28,10 +28,12 @@ public: META_Object(osgText,FadeText) - typedef std::map ViewBlendColourMap; - - ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; } - const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; } + + /** Set the speed that the alpha value changes as the text is occluded or becomes visible.*/ + void setFadeSpeed(float fadeSpeed) { _fadeSpeed = fadeSpeed; } + + /** Get the speed that the alpha value changes.*/ + float getFadeSpeed() const { return _fadeSpeed; } /** Draw the text.*/ virtual void drawImplementation(osg::RenderInfo& renderInfo) const; @@ -41,6 +43,16 @@ protected: virtual ~FadeText() {} void init(); + + struct FadeTextUpdateCallback; + friend struct FadeTextUpdateCallback; + + typedef std::map ViewBlendColourMap; + + ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; } + const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; } + + float _fadeSpeed; mutable ViewBlendColourMap _viewBlendColourMap; }; diff --git a/src/osgText/FadeText.cpp b/src/osgText/FadeText.cpp index 801f6c0d1..f3a268dfa 100644 --- a/src/osgText/FadeText.cpp +++ b/src/osgText/FadeText.cpp @@ -273,7 +273,7 @@ GlobalFadeText* getGlobalFadeText() return s_globalFadeText.get(); } -struct FadeTextUpdateCallback : public osg::Drawable::UpdateCallback +struct FadeText::FadeTextUpdateCallback : public osg::Drawable::UpdateCallback { FadeTextData _ftd; @@ -291,7 +291,7 @@ struct FadeTextUpdateCallback : public osg::Drawable::UpdateCallback _ftd._fadeText = fadeText; - float fadeSpeed = 0.01f; + float fadeSpeed = fadeText->getFadeSpeed(); GlobalFadeText::ViewFadeTextMap& vftm = gft->_viewFadeTextMap; for(GlobalFadeText::ViewFadeTextMap::iterator itr = vftm.begin(); @@ -342,6 +342,7 @@ FadeText::FadeText(const Text& text,const osg::CopyOp& copyop): void FadeText::init() { + _fadeSpeed = 0.01f; setUpdateCallback(new FadeTextUpdateCallback()); }