-#include <plib/ssg.h>
+#ifndef FG_PANELNODE_HXX
+#define FG_PANELNODE_HXX
+
+#include <osg/Vec3>
+#include <osg/Matrix>
+#include <osg/Drawable>
+
+#include <simgear/structure/SGSharedPtr.hxx>
+#include <simgear/props/props.hxx>
class FGPanel;
class SGPropertyNode;
-// PanelNode defines an SSG leaf object that draws a FGPanel object
-// into the scene graph. Note that this is an incomplete SSG object,
-// many methods, mostly involved with modelling and runtime
-// inspection, are unimplemented.
+// PanelNode defines an OSG drawable wrapping the 2D panel drawing code
-// Static mouse handler for all FGPanelNodes. Very clumsy; this
-// should really be done through our container (an aircraft model,
-// typically).
-bool fgHandle3DPanelMouseEvent(int button, int updown, int x, int y);
-void fgUpdate3DPanels();
-
-class FGPanelNode : public ssgLeaf
+class FGPanelNode : public osg::Drawable
{
-protected:
- virtual void draw_geometry();
-
public:
+ FGPanelNode();
+
FGPanelNode(SGPropertyNode* props);
virtual ~FGPanelNode();
- virtual void draw();
- bool doMouseAction(int button, int updown, int x, int y);
+ // OSGFIXME
+ virtual osg::Object* cloneType() const { return 0; }
+ virtual osg::Object* clone(const osg::CopyOp& copyop) const { return 0; }
FGPanel* getPanel() { return _panel; }
- virtual void recalcBSphere() { bsphere_is_invalid = 0; }
-
- //
- // A bunch of Plib functions that aren't implemented. I don't
- // even know what many of them do, but they're pure virtual and
- // require implementation.
- //
- virtual int getNumTriangles() { die(); return 0; }
- virtual void getTriangle(int n, short* v1, short* v2, short* v3) { die(); }
- virtual int getNumLines() { die(); return 0; }
- virtual void getLine(int n, short* v1, short* v2) { die(); }
-
- virtual void drawHighlight(sgVec4 colour) { die(); }
- virtual void drawHighlight(sgVec4 colour, int i) { die(); }
- virtual float* getVertex(int i) { die(); return 0; }
- virtual float* getNormal(int i) { die(); return 0; }
- virtual float* getColour(int i) { die(); return 0; }
- virtual float* getTexCoord(int i) { die(); return 0; }
- virtual void pick(int baseName) { die(); }
- virtual void isect_triangles(sgSphere* s, sgMat4 m, int testNeeded) { die(); }
- virtual void hot_triangles(sgVec3 s, sgMat4 m, int testNeeded) { die(); }
- virtual void los_triangles(sgVec3 s, sgMat4 m, int testNeeded) { die(); }
- virtual void transform(const sgMat4 m) { die(); }
+ virtual void drawImplementation(osg::RenderInfo& renderInfo) const
+ { drawImplementation(*renderInfo.getState()); }
+
+ void drawImplementation(osg::State& state) const;
+ virtual osg::BoundingBox computeBound() const;
+ /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */
+ virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
+
+ virtual void accept(osg::PrimitiveFunctor& functor) const;
+
+ static osg::Node* load(SGPropertyNode *n);
+ static osg::Node* create2DPanelNode();
+
+ osg::Matrix transformMatrix() const;
+
+ void setPanelPath(const std::string& panel);
+ void lazyLoad();
+
+ /**
+ * is visible in 2D mode or not?
+ */
+ bool isVisible2d() const;
private:
- // Handler for all the unimplemented methods above
- void die();
-
- FGPanel* _panel;
-
+ void commonInit();
+ void initWithPanel();
+
+ SGSharedPtr<FGPanel> _panel;
+ std::string _panelPath;
+
+ bool _resizeToViewport;
+ bool _depthTest;
+
// Panel corner coordinates
- float _bottomLeft[3], _topLeft[3], _bottomRight[3];
+ osg::Vec3 _bottomLeft, _topLeft, _bottomRight;
- // The input range expected in the panel definition. These x/y
- // coordinates will map to the right/top sides.
- float _xmax, _ymax;
-
+ int _xmin, _ymin, _xmax, _ymax;
+
// The matrix that results, which transforms 2D x/y panel
// coordinates into 3D coordinates of the panel quadrilateral.
- GLfloat _xform[16];
-
- // The matrix transformation state that was active the last time
- // we were rendered. Used by the mouse code to compute
- // intersections.
- GLfloat _lastModelview[16];
- GLfloat _lastProjection[16];
- GLint _lastViewport[4];
+ osg::Matrix _xform;
+
+ /// should the 2D panel auto-hide when the view orientation changes
+ mutable SGPropertyNode_ptr _autoHide2d;
+
+ /// should the 2D panel be hidden in views other than the default (view 0)
+ mutable SGPropertyNode_ptr _hideNonDefaultViews;
};
+
+
+#endif // FG_PANELNODE_HXX