00001 // Copyright (C) 2006 University of Louisiana at Lafayette 00002 // Authors: Suresh Golconda, Christopher Mire 00003 00004 #ifndef VRJ_INTERFACE_H 00005 #define VRJ_INTERFACE_H 00006 00007 #include "interface.H" 00008 00009 #include <vrj/Kernel/Kernel.h> 00010 #include <vrj/Draw/OGL/GlApp.h> 00011 00012 // Added for keyboard 00013 #include <boost/shared_ptr.hpp> 00014 #include <gadget/Type/KeyboardMouseInterface.h> 00015 #include <gadget/Type/KeyboardMouse/KeyEvent.h> 00016 #include <gadget/Type/KeyboardMouse/MouseEvent.h> 00017 #include <gadget/Type/AnalogInterface.h> 00018 #include <gadget/Type/PositionProxy.h> 00019 00020 #include <gmtl/Matrix.h> 00021 #include <gmtl/Generate.h> 00022 00023 using namespace gmtl; 00024 00025 namespace cajun 00026 { 00027 class vrj_drawing_interface_t; 00028 // ------------------- vrj interface ------------------- 00029 class vrj_interface_t : public graphic_interface_t 00030 { 00031 public: 00032 ~vrj_interface_t (); 00033 void register_graphics (drawing_t *graphics); 00034 void init_interface (int argc, char **argv, char const *terrain_model, 00035 char const *sky_model, char const *conf_filename); 00036 void start_interface (); 00037 void draw_callback (); 00038 void intra_update_callback (); 00039 void update_callback (); 00040 void dynamic_data_callback (); 00041 00042 void normalKey_callback (unsigned char key); 00043 void controlKey_callback (int key); 00044 void mousebutton_callback (int button, int state, 00045 int x, int y); 00046 void mousemotion_callback (int x, int y); 00047 void set_controlKey_index (); 00048 void set_modifierKey (int key); 00049 private: 00050 int m_controlKey_index [MAX_CONTROLKEY_INDEX]; 00051 int m_modifierKey; 00052 int m_mouseKey_index [MAX_MOUSEKEY_INDEX]; 00053 int m_mouseState_index [MAX_MOUSESTATE_INDEX]; 00054 vrj::Kernel* kernel; 00055 vrj_drawing_interface_t *m_vrj_drawing_interface; 00056 }; 00057 00058 // ------------------- vrj drawing interface ------------------- 00059 class vrj_drawing_interface_t : public vrj::GlApp 00060 { 00061 public: 00062 vrj_drawing_interface_t (vrj_interface_t *vrj_interface_) 00063 : m_vrj_interface (vrj_interface_) {} 00064 private: 00065 vrj_interface_t *m_vrj_interface; 00066 00067 bool m_joysticks_ok; 00068 float wand[4][4]; 00069 float wand_color[3]; 00070 Matrix44f wand_matrix; 00071 00072 float joystick_data; 00073 00074 gadget::KeyboardMouseInterface mKeyboard; 00075 gadget::PositionInterface mWand; 00076 gadget::PositionInterface mHead; 00077 gadget::DigitalInterface mButton0; 00078 gadget::DigitalInterface mButton1; 00079 gadget::DigitalInterface mButton2; 00080 gadget::DigitalInterface mButton3; 00081 gadget::DigitalInterface mButton4; 00082 gadget::DigitalInterface mButton5; 00084 gadget::DigitalInterface mButton6; 00085 gadget::DigitalInterface mButton7; 00086 gadget::DigitalInterface mButton8; 00087 gadget::DigitalInterface mButton9; 00088 gadget::DigitalInterface mButton10; 00089 gadget::DigitalInterface mButton11; 00091 gadget::AnalogInterface mJoy0; 00092 gadget::AnalogInterface mJoy1; 00093 gadget::AnalogInterface mJoy2; 00094 gadget::AnalogInterface mJoy3; 00095 gadget::AnalogInterface mJoy4; 00096 gadget::AnalogInterface mJoy5; 00098 // ------- GlApp members ----------------- 00099 virtual void init () 00100 { 00101 m_joysticks_ok = false; 00102 wand_color[0] = 00103 wand_color[1] = 00104 wand_color[2] = 0.7f; 00105 mKeyboard.init ("VJKeyboard"); 00106 mWand.init ("VJWand"); 00107 mHead.init ("VJHead"); 00108 00109 // lite jconf files 00110 mButton0.init ("CBButton01"); 00111 mButton1.init ("CBButton02"); 00112 mButton2.init ("CBButton03"); 00113 mButton3.init ("CBButton04"); 00114 mButton4.init ("CBButton05"); 00115 mButton5.init ("CBButton06"); 00116 mButton6.init ("CBButton07"); 00117 mButton7.init ("CBButton08"); 00118 mButton8.init ("CBButton09"); 00119 mButton9.init ("CBButton10"); 00120 mButton10.init ("CBButton11"); 00121 mButton11.init ("CBButton12"); 00122 mJoy0.init ("CBAnalog01"); 00123 mJoy1.init ("CBAnalog02"); 00124 mJoy2.init ("CBAnalog03"); 00125 mJoy3.init ("CBAnalog04"); 00126 mJoy4.init ("CBAnalog05"); 00127 mJoy5.init ("CBAnalog06"); 00128 } 00129 virtual void apiInit () {;} 00130 00131 virtual void bufferPreDraw (); 00132 virtual void contextPreDraw (); 00133 virtual void preFrame (); 00134 00135 virtual void intraFrame (); 00136 virtual void postFrame () {;} 00137 00138 // ----- OpenGL FUNCTIONS ---- // 00139 virtual void contextInit (); 00140 virtual void draw (); 00141 00142 }; 00143 }; 00144 #endif