]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/CanvasObjectPlacement.hxx
Add simple keyboard event demo application.
[simgear.git] / simgear / canvas / CanvasObjectPlacement.hxx
1 ///@file
2 /// Placement for putting a canvas texture onto OpenSceneGraph objects.
3 ///
4 /// It also provides a SGPickCallback for passing mouse events to the canvas and
5 /// manages emissive lighting of the placed canvas.
6 //
7 // Copyright (C) 2013  Thomas Geymayer <tomgey@gmail.com>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // Library General Public License for more details.
18 //
19 // You should have received a copy of the GNU Library General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
22
23 #ifndef CANVAS_OBJECT_PLACEMENT_HXX_
24 #define CANVAS_OBJECT_PLACEMENT_HXX_
25
26 #include "CanvasPlacement.hxx"
27 #include "canvas_fwd.hxx"
28
29 #include <simgear/scene/util/SGSceneUserData.hxx>
30 #include <osg/Material>
31
32 namespace simgear
33 {
34 namespace canvas
35 {
36
37   /**
38    * Place a Canvas onto an osg object (as texture).
39    */
40   class ObjectPlacement:
41     public Placement
42   {
43     public:
44
45       typedef osg::ref_ptr<osg::Group> GroupPtr;
46       typedef osg::ref_ptr<osg::Material> MaterialPtr;
47
48       ObjectPlacement( SGPropertyNode* node,
49                        const GroupPtr& group,
50                        const CanvasWeakPtr& canvas );
51       virtual ~ObjectPlacement();
52
53       /**
54        * Set emissive lighting of the object the canvas is placed on.
55        */
56       void setEmission(float emit);
57
58       /**
59        * Set whether pick events should be captured.
60        */
61       void setCaptureEvents(bool enable);
62
63       virtual bool childChanged(SGPropertyNode* child);
64
65     protected:
66       typedef SGSharedPtr<SGPickCallback> PickCallbackPtr;
67       typedef osg::ref_ptr<SGSceneUserData> SGSceneUserDataPtr;
68
69       GroupPtr            _group;
70       MaterialPtr         _material;
71       CanvasWeakPtr       _canvas;
72       PickCallbackPtr     _pick_cb;
73       SGSceneUserDataPtr  _scene_user_data;
74   };
75
76 } // namespace canvas
77 } // namespace simgear
78
79 #endif /* CANVAS_OBJECT_PLACEMENT_HXX_ */