CEDRIC  Revision_backup-2009-02
ChangeColorVisitor.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2008 Boris Iven, Max Hermann
4  *
5  * This file is part of the "CEDRIC Event Display" application.
6  *
7  *****************************************************************************/
8 
9 #ifndef CHANGECOLORVISITOR_H_
10 #define CHANGECOLORVISITOR_H_
11 
12 #include <osg/NodeVisitor>
13 #include <osg/StateSet>
14 #include <osg/Vec3>
15 #include <osg/Vec4>
16 
17 class osg::Geode;
18 
19 
21 class ChangeColorVisitor : public osg::NodeVisitor
22 {
23 public:
24  ChangeColorVisitor( osg::Vec3 color=osg::Vec3(1.0,1.0,1.0) );
25 
27  void reset();
28 
30  void changeOnlyAlpha( bool b );
31 
33  void setColor( osg::Vec4 color );
34 
36  void setColor( osg::Vec3 color );
37 
39  void setAlpha( float alpha );
40 
42  virtual void apply( osg::Geode& geode );
43 
45  int getNumberOfChangedDrawables() const;
46 
49 
50 protected:
52  void ChangeColorVisitor::setBlendState( osg::StateSet* stateSet );
53 
54  osg::Vec4 m_color;
57 
59 };
60 
61 #endif /*CHANGECOLORVISITOR_H_*/
osg::Vec4 m_color
Definition: ChangeColorVisitor.h:54
virtual void apply(osg::Geode &geode)
Visitor implementation goes here.
Definition: ChangeColorVisitor.cpp:85
int getNumberOfChangedDrawables() const
Return number of changed drawables since last reset() call.
Definition: ChangeColorVisitor.cpp:46
void setColor(osg::Vec4 color)
Set RGBA color.
void setBlendState(osg::StateSet *stateSet)
Enables blending (and sets blendfunc) if m_color alpha component < 1 else disables blending (applies ...
Definition: ChangeColorVisitor.cpp:68
void setChangeBlendState(bool b)
Allow/Forbid changing the blend state (by default changing blend state is forbidden) ...
Definition: ChangeColorVisitor.h:48
bool m_dontChangeBlendState
Definition: ChangeColorVisitor.h:58
void setAlpha(float alpha)
Set alpha value.
Definition: ChangeColorVisitor.cpp:63
void reset()
Only resets number of changed drawables (see getNumberOfChangedDrawables())
Definition: ChangeColorVisitor.cpp:36
bool m_AlphaOnly
Definition: ChangeColorVisitor.h:56
void changeOnlyAlpha(bool b)
Only change alpha value of drawables.
Definition: ChangeColorVisitor.cpp:41
int m_numberOfChangedDrawables
Definition: ChangeColorVisitor.h:55
ChangeColorVisitor(osg::Vec3 color=osg::Vec3(1.0, 1.0, 1.0))
Definition: ChangeColorVisitor.cpp:27
NodeVisitor for changing color or alpha of ShapeDrawables.
Definition: ChangeColorVisitor.h:21