00001 // This is brl/bbas/bgui3d/bgui3d_project2d_tableau.h 00002 #ifndef bgui3d_project2d_tableau_h_ 00003 #define bgui3d_project2d_tableau_h_ 00004 //: 00005 // \file 00006 // \brief A tableau that projects a 3D scene into a 2D image 00007 // \author Matt Leotta (mleotta@lems.brown.edu) 00008 // \date August 6, 2004 00009 // 00010 // \verbatim 00011 // Modifications 00012 // <none yet> 00013 // \endverbatim 00014 00015 #include "bgui3d_project2d_tableau_sptr.h" 00016 #include "bgui3d_tableau.h" 00017 #include <vnl/vnl_double_3x4.h> 00018 00019 00020 //: Tableau that projects a Coin3D scene graph into an image plane 00021 // The scenegraph should not contain a camera node. 00022 // The image plane is specified by 3x4 camera matrix 00023 class bgui3d_project2d_tableau : public bgui3d_tableau 00024 { 00025 public: 00026 //: Default Constructor - don't use this, use bgui3d_project2d_tableau_new. 00027 bgui3d_project2d_tableau(); 00028 //: Constructor - don't use this, use bgui3d_project2d_tableau_new. 00029 bgui3d_project2d_tableau(const vpgl_proj_camera<double>& camera, 00030 SoNode* scene_root = NULL); 00031 00032 //: Destructor 00033 virtual ~bgui3d_project2d_tableau(); 00034 00035 //: Return the type name of this tableau 00036 virtual vcl_string type_name() const; 00037 00038 //: Handle vgui events 00039 virtual bool handle(const vgui_event& event); 00040 00041 //: Set the scene camera 00042 // creates a graphics camera from a vpgl camera (either perspective or affine) 00043 virtual bool set_camera(const vpgl_proj_camera<double>& camera); 00044 00045 //: Get the scene camera 00046 // creates a vpgl camera (either perspective or affine) from the graphics camera 00047 virtual vcl_auto_ptr<vpgl_proj_camera<double> > camera() const; 00048 00049 //: Activate a headlight 00050 void set_headlight(bool enable) { draw_headlight_ = enable; this->post_redraw(); } 00051 00052 //: Is the headlight active 00053 bool is_headlight() const { return draw_headlight_; } 00054 00055 //: Builds a popup menu 00056 virtual void get_popup(const vgui_popup_params&, vgui_menu &m); 00057 00058 protected: 00059 //: setup the OpenGL projection matrix 00060 virtual bool setup_projection(); 00061 00062 private: 00063 //: The canonical camera looking down the -z axis 00064 vnl_double_3x4 camera_z_; 00065 00066 //: The GL model matrix to load for the camera position 00067 double model_matrix_[16]; 00068 00069 //: Flag for drawing a headlight 00070 bool draw_headlight_; 00071 }; 00072 00073 00074 //: Create a smart pointer to a bgui3d_project2d_tableau tableau. 00075 struct bgui3d_project2d_tableau_new : public bgui3d_project2d_tableau_sptr 00076 { 00077 typedef bgui3d_project2d_tableau_sptr base; 00078 00079 bgui3d_project2d_tableau_new() : base(new bgui3d_project2d_tableau()) { } 00080 00081 bgui3d_project2d_tableau_new(const vpgl_proj_camera<double>& camera, SoNode* scene_root = NULL) 00082 : base(new bgui3d_project2d_tableau(camera, scene_root)) { } 00083 }; 00084 00085 #endif // bgui3d_project2d_tableau_h_