Added FadeText::setFadeSpeed and made internal data structures protected.

This commit is contained in:
Robert Osfield 2006-10-24 09:06:28 +00:00
parent 648455da34
commit 85dc696c09
2 changed files with 19 additions and 6 deletions

View File

@ -28,10 +28,12 @@ public:
META_Object(osgText,FadeText) META_Object(osgText,FadeText)
typedef std::map<osg::View*, osg::Vec4 > ViewBlendColourMap;
ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; } /** Set the speed that the alpha value changes as the text is occluded or becomes visible.*/
const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; } void setFadeSpeed(float fadeSpeed) { _fadeSpeed = fadeSpeed; }
/** Get the speed that the alpha value changes.*/
float getFadeSpeed() const { return _fadeSpeed; }
/** Draw the text.*/ /** Draw the text.*/
virtual void drawImplementation(osg::RenderInfo& renderInfo) const; virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
@ -42,6 +44,16 @@ protected:
void init(); void init();
struct FadeTextUpdateCallback;
friend struct FadeTextUpdateCallback;
typedef std::map<osg::View*, osg::Vec4 > ViewBlendColourMap;
ViewBlendColourMap& getViewBlendColourMap() { return _viewBlendColourMap; }
const ViewBlendColourMap& getViewBlendColourMap() const { return _viewBlendColourMap; }
float _fadeSpeed;
mutable ViewBlendColourMap _viewBlendColourMap; mutable ViewBlendColourMap _viewBlendColourMap;
}; };

View File

@ -273,7 +273,7 @@ GlobalFadeText* getGlobalFadeText()
return s_globalFadeText.get(); return s_globalFadeText.get();
} }
struct FadeTextUpdateCallback : public osg::Drawable::UpdateCallback struct FadeText::FadeTextUpdateCallback : public osg::Drawable::UpdateCallback
{ {
FadeTextData _ftd; FadeTextData _ftd;
@ -291,7 +291,7 @@ struct FadeTextUpdateCallback : public osg::Drawable::UpdateCallback
_ftd._fadeText = fadeText; _ftd._fadeText = fadeText;
float fadeSpeed = 0.01f; float fadeSpeed = fadeText->getFadeSpeed();
GlobalFadeText::ViewFadeTextMap& vftm = gft->_viewFadeTextMap; GlobalFadeText::ViewFadeTextMap& vftm = gft->_viewFadeTextMap;
for(GlobalFadeText::ViewFadeTextMap::iterator itr = vftm.begin(); for(GlobalFadeText::ViewFadeTextMap::iterator itr = vftm.begin();
@ -342,6 +342,7 @@ FadeText::FadeText(const Text& text,const osg::CopyOp& copyop):
void FadeText::init() void FadeText::init()
{ {
_fadeSpeed = 0.01f;
setUpdateCallback(new FadeTextUpdateCallback()); setUpdateCallback(new FadeTextUpdateCallback());
} }