openscenegraph
StateSetManipulator
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
26namespace osgGA {
27
28/**
29Experimental class, not been looked at for a while, but which will
30be returned to at some point :-\
31*/
32class OSGGA_EXPORT StateSetManipulator : public GUIEventHandler
33{
34public:
35
36 StateSetManipulator(osg::StateSet* stateset=0);
37
38 virtual const char* className() const { return "StateSetManipulator"; }
39
40 /** attach a StateSet to the manipulator to be used for specifying view.*/
41 virtual void setStateSet(osg::StateSet*);
42
43 /** get the attached a StateSet.*/
44 virtual osg::StateSet * getStateSet();
45
46 /** get the attached a StateSet.*/
47 virtual const osg::StateSet * getStateSet() const;
48
49
50 /** Handle events, return true if handled, false otherwise.*/
51 virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
52
53 /** Get the keyboard and mouse usage of this manipulator.*/
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
86protected:
87
88 virtual ~StateSetManipulator();
89
90 void clone();
91
92 osg::ref_ptr<osg::StateSet> _stateset;
93
94 bool _initialized;
95 bool _backface;
96 bool _lighting;
97 bool _texture;
98 unsigned int _maxNumOfTextureUnits;
99
100 int _keyEventToggleBackfaceCulling;
101 int _keyEventToggleLighting;
102 int _keyEventToggleTexturing;
103 int _keyEventCyclePolygonMode;
104
105 osg::PolygonMode* getOrCreatePolygonMode();
106};
107
108}
109
110#endif