]> git.mxchange.org Git - flightgear.git/blob - src/Model/panelnode.hxx
Work on making 2D panels act like standard scene-graph elements for picking and drawing.
[flightgear.git] / src / Model / panelnode.hxx
1 #ifndef FG_PANELNODE_HXX
2 #define FG_PANELNODE_HXX
3
4 #include <osg/Vec3>
5 #include <osg/Matrix>
6 #include <osg/Drawable>
7
8 class FGPanel;
9 class SGPropertyNode;
10
11 // PanelNode defines an OSG drawable wrapping the 2D panel drawing code
12
13 class FGPanelNode : public osg::Drawable
14 {
15 public:
16     FGPanelNode(FGPanel* panel);
17   
18     FGPanelNode(SGPropertyNode* props);
19     virtual ~FGPanelNode();
20
21     // OSGFIXME
22     virtual osg::Object* cloneType() const { return 0; }
23     virtual osg::Object* clone(const osg::CopyOp& copyop) const { return 0; }        
24
25     FGPanel* getPanel() { return _panel; }
26
27     virtual void drawImplementation(osg::RenderInfo& renderInfo) const
28     { drawImplementation(*renderInfo.getState()); }
29   
30     void drawImplementation(osg::State& state) const;
31     virtual osg::BoundingBox computeBound() const;
32
33     /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */
34     virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
35   
36     virtual void accept(osg::PrimitiveFunctor& functor) const;
37   
38     static osg::Node* load(SGPropertyNode *n);
39     static osg::Node* createNode(FGPanel* panel);
40   
41     osg::Matrix transformMatrix() const;
42   
43 private:
44     void initWithPanel();
45     
46     FGPanel* _panel;
47   
48     bool _resizeToViewport;
49
50     // Panel corner coordinates
51     osg::Vec3 _bottomLeft, _topLeft, _bottomRight;
52
53     // The input range expected in the panel definition.  These x/y
54     // coordinates will map to the right/top sides.
55     float _xmax, _ymax;
56     
57     // The matrix that results, which transforms 2D x/y panel
58     // coordinates into 3D coordinates of the panel quadrilateral.
59     osg::Matrix _xform;
60 };
61
62
63 #endif // FG_PANELNODE_HXX