File: StateSetManipulator

package info (click to toggle)
openscenegraph 3.2.3%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 32,824 kB
  • sloc: cpp: 370,040; ansic: 9,071; java: 1,020; yacc: 548; objc: 288; makefile: 285; xml: 155; lex: 151
file content (110 lines) | stat: -rw-r--r-- 3,703 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSGGA_STATESET_MANIPULATOR
#define OSGGA_STATESET_MANIPULATOR 1

#include <osgGA/Export>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIActionAdapter>
#include <osgGA/GUIEventHandler>

#include <osg/StateSet>
#include <osg/PolygonMode>


namespace osgGA {

/**
Experimental class, not been looked at for a while, but which will
be returned to at some point :-\
*/
class OSGGA_EXPORT StateSetManipulator : public GUIEventHandler
{
public:

        StateSetManipulator(osg::StateSet* stateset=0);

        virtual const char* className() const { return "StateSetManipulator"; }

        /** attach a StateSet to the manipulator to be used for specifying view.*/
        virtual void setStateSet(osg::StateSet*);

        /** get the attached a StateSet.*/
        virtual osg::StateSet * getStateSet();

        /** get the attached a StateSet.*/
        virtual const osg::StateSet * getStateSet() const;


        /** Handle events, return true if handled, false otherwise.*/
        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);

        /** Get the keyboard and mouse usage of this manipulator.*/
        virtual void getUsage(osg::ApplicationUsage& usage) const;

        void setMaximumNumOfTextureUnits(unsigned int i) { _maxNumOfTextureUnits = i; }
        unsigned int getMaximumNumOfTextureUnits() const { return _maxNumOfTextureUnits; }

        void setBackfaceEnabled(bool newbackface);
        bool getBackfaceEnabled() const {return _backface;};

        void setLightingEnabled(bool newlighting);
        bool getLightingEnabled() const {return _lighting;};

        void setTextureEnabled(bool newtexture);
        bool getTextureEnabled() const {return _texture;};

        void setPolygonMode(osg::PolygonMode::Mode newpolygonmode);
        osg::PolygonMode::Mode getPolygonMode() const;

        void cyclePolygonMode();


        void setKeyEventToggleBackfaceCulling(int key) { _keyEventToggleBackfaceCulling = key; }
        int getKeyEventToggleBackfaceCulling() const { return _keyEventToggleBackfaceCulling; }

        void setKeyEventToggleLighting(int key) { _keyEventToggleLighting = key; }
        int getKeyEventToggleLighting() const { return _keyEventToggleLighting; }

        void setKeyEventToggleTexturing(int key) { _keyEventToggleTexturing = key; }
        int getKeyEventToggleTexturing() const { return _keyEventToggleTexturing; }

        void setKeyEventCyclePolygonMode(int key) { _keyEventCyclePolygonMode = key; }
        int getKeyEventCyclePolygonMode() const { return _keyEventCyclePolygonMode; }

protected:

        virtual ~StateSetManipulator();

        void clone();

        osg::ref_ptr<osg::StateSet> _stateset;

        bool _initialized;
        bool _backface;
        bool _lighting;
        bool _texture;
        unsigned int _maxNumOfTextureUnits;

        int _keyEventToggleBackfaceCulling;
        int _keyEventToggleLighting;
        int _keyEventToggleTexturing;
        int _keyEventCyclePolygonMode;

        osg::PolygonMode* getOrCreatePolygonMode();
};

}

#endif