Cosmetics + started to add support for cairo drawing to eventually replace the X...
[universe.git] / manipulator.h
1
2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
4
5 #ifndef MANIPULATOR_CC
6 #define MANIPULATOR_CC
7
8 #include "misc.h"
9 #include "map.h"
10 #include "universe.h"
11 #include "task.h"
12
13 class Manipulator : public Map {
14   static const int sqsize = 16;
15   Polygon *_touching_polygon, *_current_polygon;
16   scalar_t _grab_relative_x, _grab_relative_y;
17   scalar_t _xmax, _ymax;
18   scalar_t _hand_x, _hand_y;
19   scalar_t _force_x, _force_y;
20   bool _grab, _release;
21   int _current_action;
22   enum { FEEL_TOUCHING_OBJECT, FEEL_GRABBING_OBJECT, NB_DISCRETE_PARAMETERS };
23   enum { MAP_LOCATION_X, MAP_LOCATION_Y, MAP_RESISTANCE_X, MAP_RESISTANCE_Y, NB_CONTINUOUS_MAPS };
24   static const int continuous_map_size = 25;
25   scalar_t _kernel_continuous_maps[continuous_map_size * 2 + 1];
26 public:
27   enum { ACTION_IDLE,
28          ACTION_MOVE_UP, ACTION_MOVE_RIGHT, ACTION_MOVE_DOWN, ACTION_MOVE_LEFT,
29          ACTION_GRAB, ACTION_RELEASE,
30          NB_ACTIONS };
31   Manipulator(Task *task);
32
33   inline scalar_t hand_x() { return _hand_x; }
34   inline scalar_t hand_y() { return _hand_y; }
35   inline Polygon *grabbing() { return _current_polygon; }
36
37   int nb_actions();
38   void do_action(int action);
39
40   void update_map();
41   void update(scalar_t dt, Universe *universe);
42
43   int parameter_width();
44   int parameter_height();
45   void draw_parameters(int x0, int y0, SimpleWindow *window);
46   void draw_on_universe(SimpleWindow *window);
47
48   int random_action();
49
50 //   void force_grab(Universe *universe, scalar_t x, scalar_t y);
51   void force_move(scalar_t x, scalar_t y);
52   void force_release();
53 };
54
55 #endif