1
0
Fork 0
flightgear/src/Model/panelnode.hxx
curt 72017fc671 Andy Ross:
The biggest and coolest patch adds mouse sensitivity to the 3D
cockpits, so we can finally work the radios.  This ended up requiring
significant modifications outside of the 3D cockpit code.  Stuff folks
will want to look at:

+ The list of all "3D" cockpits is stored statically in the
   panelnode.cxx file.  This is clumsy, and won't migrate well to a
   multiple-aircraft feature.  Really, there should be a per-model list
   of 3D panels, but I couldn't find a clean place to put this.  The
   only handle you get back after parsing a model is a generic ssg
   node, to which I obviously can't add panel-specific methods.

+ The aircraft model is parsed *very* early in the initialization
   order.  Earlier, in fact, than the static list of allowable command
   bindings is built in fgInitCommands().  This is bad, as it means
   that mouse bindings on the instruments can't work yet.  I moved the
   call to fgInitCommands, but someone should look carefully to see
   that I picked the right place.  There's a lot of initialization
   code, and I got a little lost in there... :)

+ I added yet another "update" hook to the fgRenderFrame routine to
   hook the updates for the 3D panels.  This is only required for
   "mouse press delay", and it's a fairly clumsy mechanism based on
   frame rate instead of real time.  There appears to be delay handling
   already in place in the Input stuff, and there's a discussion going
   on about different mouse behavior right now.  Maybe this is a good
   time to unify these two (now three) approaches?
2002-10-29 19:44:03 +00:00

78 lines
2.7 KiB
C++

#include <plib/ssg.h>
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.
// 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
{
protected:
virtual void draw_geometry();
public:
FGPanelNode(SGPropertyNode* props);
virtual ~FGPanelNode();
virtual void draw();
bool doMouseAction(int button, int updown, int x, int y);
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(); }
private:
// Handler for all the unimplemented methods above
void die();
FGPanel* _panel;
// Panel corner coordinates
float _bottomLeft[3], _topLeft[3], _bottomRight[3];
// The input range expected in the panel definition. These x/y
// coordinates will map to the right/top sides.
float _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];
};