OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StateSetManipulator.h
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 OSGGA_STATESET_MANIPULATOR
15 #define OSGGA_STATESET_MANIPULATOR 1
16 
17 #include <osgGA/Export>
18 #include <osgGA/GUIEventAdapter>
19 #include <osgGA/GUIActionAdapter>
20 #include <osgGA/GUIEventHandler>
21 
22 #include <osg/StateSet>
23 #include <osg/PolygonMode>
24 
25 
26 namespace osgGA {
27 
33 {
34 public:
35 
37 
38  virtual const char* className() const { return "StateSetManipulator"; }
39 
41  virtual void setStateSet(osg::StateSet*);
42 
44  virtual osg::StateSet * getStateSet();
45 
47  virtual const osg::StateSet * getStateSet() const;
48 
49 
51  virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
52 
54  virtual void getUsage(osg::ApplicationUsage& usage) const;
55 
56  void setMaximumNumOfTextureUnits(unsigned int i) { _maxNumOfTextureUnits = i; }
57  unsigned int getMaximumNumOfTextureUnits() const { return _maxNumOfTextureUnits; }
58 
59  void setBackfaceEnabled(bool newbackface);
60  bool getBackfaceEnabled() const {return _backface;};
61 
62  void setLightingEnabled(bool newlighting);
63  bool getLightingEnabled() const {return _lighting;};
64 
65  void setTextureEnabled(bool newtexture);
66  bool getTextureEnabled() const {return _texture;};
67 
68  void setPolygonMode(osg::PolygonMode::Mode newpolygonmode);
69  osg::PolygonMode::Mode getPolygonMode() const;
70 
71  void cyclePolygonMode();
72 
73 
74  void setKeyEventToggleBackfaceCulling(int key) { _keyEventToggleBackfaceCulling = key; }
75  int getKeyEventToggleBackfaceCulling() const { return _keyEventToggleBackfaceCulling; }
76 
77  void setKeyEventToggleLighting(int key) { _keyEventToggleLighting = key; }
78  int getKeyEventToggleLighting() const { return _keyEventToggleLighting; }
79 
80  void setKeyEventToggleTexturing(int key) { _keyEventToggleTexturing = key; }
81  int getKeyEventToggleTexturing() const { return _keyEventToggleTexturing; }
82 
83  void setKeyEventCyclePolygonMode(int key) { _keyEventCyclePolygonMode = key; }
84  int getKeyEventCyclePolygonMode() const { return _keyEventCyclePolygonMode; }
85 
86 protected:
87 
88  virtual ~StateSetManipulator();
89 
90  void clone();
91 
93 
95  bool _backface;
96  bool _lighting;
97  bool _texture;
98  unsigned int _maxNumOfTextureUnits;
99 
104 
105  osg::PolygonMode* getOrCreatePolygonMode();
106 };
107 
108 }
109 
110 #endif
virtual const char * className() const
void setKeyEventToggleBackfaceCulling(int key)
T * clone(const T *t, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition: Object.h:242
osg::ref_ptr< osg::StateSet > _stateset
#define OSGGA_EXPORT
Definition: Export.h:40
void setKeyEventCyclePolygonMode(int key)
void setKeyEventToggleTexturing(int key)
int getKeyEventToggleBackfaceCulling() const
void setMaximumNumOfTextureUnits(unsigned int i)
unsigned int getMaximumNumOfTextureUnits() const