SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
ChaiGlutHandlers.hpp
1 /* This file is part of scl, a control and simulation library
2 for robots and biomechanical models.
3 
4 scl is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8 
9 Alternatively, you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 scl is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License and a copy of the GNU General Public License along with
21 scl. If not, see <http://www.gnu.org/licenses/>.
22 */
23 /* \file ChaiGlutHandlers.hpp
24  *
25  * Created on: Oct 27, 2010
26  *
27  * Copyright (C) 2010
28  *
29  * Author: Samir Menon <smenon@stanford.edu>
30  */
31 
32 /* Handler functions for chai.
33  *
34  * NOTE : Right now, scl only supports a single glut display
35  * instance. It renders the first chai graphics instance
36  * by default.
37  */
38 
39 #ifndef CHAIGLUTHANDLERS_HPP_
40 #define CHAIGLUTHANDLERS_HPP_
41 
42 #include <scl/DataTypes.hpp>
43 #include <scl/Singletons.hpp>
44 #include <sutil/CSingleton.hpp>
45 
46 #include "chai3d.h"
47 #include <scl/graphics/chai/CGraphicsChai.hpp>
48 
49 #include <string>
50 #include <iostream>
51 #include <sstream>
52 #include <stdexcept>
53 
54 namespace scl_chai_glut_interface
55 {
56  //---------------------------------------------------------------------------
57  // DECLARED GLOBALS & DATA
58  //---------------------------------------------------------------------------
60  {
61  public:
62  static const scl::sUInt OPTION_FULLSCREEN=0;
63  static const scl::sUInt OPTION_WINDOWDISPLAY=1;
64  static const scl::sUInt OPTION_TOGGLE_MOUSE_CAM_SELECT=2;
65 
66  scl::SGraphicsChai* GLOB_chaiDbptr; //GLOB == Global var.
67  scl::SGraphicsParsed* GLOB_gr_parsed_ds;
68 
69  //Window information (and thus not stored in the
70  //graphics--unlike the GL width and height)
71  scl::sInt GLOB_windowPosX;
72  scl::sInt GLOB_windowPosY;
73 
76  scl::sFloat cam_sph_x_,cam_sph_h_,cam_sph_v_;
77 
79  scl::sFloat cam_lookat_x_, cam_lookat_y_, cam_lookat_z_;
80 
81  scl::CGraphicsChai *chai_glut;
82 
83  scl::sBool chai_glut_running;
84 
85  scl::sBool keys_active[256];
86 
88  SChaiGlobals();
89  };
90 
93 
94  //---------------------------------------------------------------------------
95  // DECLARED FUNCTIONS
96  //---------------------------------------------------------------------------
97  bool initializeGlutForChai(const std::string & arg_graphics_name,
98  scl::CGraphicsChai *arg_chai_glut);
99 
100  // Initializes glut from a data structure instead of the databse
101  bool initializeGlutForChai(scl::SGraphicsParsed* arg_gr_parsed_ds,
102  scl::CGraphicsChai *arg_chai_glut);
103 
104  // callback when the window display is resized
105  void resizeWindow(int w, int h);
106 
107  // callback when a keyboard key is pressed
108  void keyPressed(unsigned char key, int x, int y);
109 
110  // callback when a keyboard key is released
111  void keyReleased(unsigned char key, int x, int y);
112 
113  // callback when a keyboard key is pressed
114  void keyHandler();
115 
116  // callback when the right mouse button is pressed to select a menu item
117  void menuSelect(int value);
118 
119  // function called before exiting the application
120  void closeChaiGlut(void);
121 
122  // main graphics callback
123  void updateGraphics(void);
124 
125  // callback to handle mouse click
126  void mouseClick(int button, int state, int x, int y);
127 
128  // callback to handle mouse motion
129  void mouseMove(int x, int y);
130 
131  // callback to handle mouse motion
132  void mousePassiveMove(int x, int y);
133 
134  // function to update the viewing screen
135  void updateCameraPosition();
136 }
137 
138 #endif /* CHAIGLUTHANDLERS_HPP_ */
Definition: CGraphicsChai.hpp:48
scl::sFloat cam_lookat_x_
Definition: ChaiGlutHandlers.hpp:79
Definition: CSingleton.hpp:47
Definition: SGraphicsChai.hpp:74
bool sBool
Definition: DataTypes.hpp:54
Definition: ChaiGlutHandlers.hpp:59
scl::sFloat cam_sph_x_
Definition: ChaiGlutHandlers.hpp:76
Definition: SGraphicsParsed.hpp:48
SChaiGlobals()
Definition: ChaiGlutHandlers.cpp:48
double sFloat
Definition: DataTypes.hpp:72
int sInt
Definition: DataTypes.hpp:64