2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
13 class Manipulator : public Map {
14 static const int sqsize = 16;
16 Polygon *_touching_polygon, *_current_polygon;
17 scalar_t _grab_relative_x, _grab_relative_y;
18 scalar_t _xmax, _ymax;
19 scalar_t _hand_x, _hand_y;
20 scalar_t _force_x, _force_y;
24 enum { FEEL_TOUCHING_OBJECT, FEEL_GRABBING_OBJECT, NB_DISCRETE_PARAMETERS };
26 enum { MAP_LOCATION_X, MAP_LOCATION_Y, MAP_RESISTANCE_X, MAP_RESISTANCE_Y, NB_CONTINUOUS_MAPS };
28 static const int continuous_map_size = 25;
30 scalar_t _kernel_continuous_maps[continuous_map_size * 2 + 1];
36 ACTION_MOVE_UP, ACTION_MOVE_RIGHT, ACTION_MOVE_DOWN, ACTION_MOVE_LEFT,
37 ACTION_GRAB, ACTION_RELEASE,
41 Manipulator(Task *task);
43 inline scalar_t hand_x() { return _hand_x; }
44 inline scalar_t hand_y() { return _hand_y; }
45 inline Polygon *grabbing() { return _current_polygon; }
48 void do_action(int action);
51 void update(scalar_t dt, Universe *universe);
53 int parameter_width();
54 int parameter_height();
55 void draw_parameters(int x0, int y0, SimpleWindow *window);
56 void draw_on_universe(SimpleWindow *window);
60 // void force_grab(Universe *universe, scalar_t x, scalar_t y);
61 void force_move(scalar_t x, scalar_t y);