fixed libresman renamed resman_lookup to resman_add
[antikythera] / src / machine.h
1 #ifndef MACHINE_H_
2 #define MACHINE_H_
3
4 #include <vector>
5 #include <map>
6 #include "gear.h"
7
8 struct Motor {
9         float speed;    /* signed to denote direction, in Hz */
10         int drive;              /* which gear it drives */
11 };
12
13 class Machine {
14 private:
15         std::vector<Gear*> gears;
16         std::map<Gear*, int> gearidx;
17         bool **meshing;
18         bool meshing_valid;
19         bool *visited;  /* used for update_gear */
20
21         std::vector<Motor> motors;
22
23         void update_gear(int idx, float angle);
24
25 public:
26         Machine();
27         ~Machine();
28
29         void add_gear(Gear *g); /* takes ownership */
30         void add_motor(int gearidx, float speed_hz);
31
32         int get_gear_index(Gear *g) const;
33
34         void invalidate_meshing();
35         void calc_meshing();
36
37         void update(float dt);
38         void draw() const;
39
40         Gear *intersect_gear(const Ray &ray, HitPoint *hitp = 0) const;
41 };
42
43 #endif  // MACHINE_H_