- added subgear linkage
[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         void invalidate_meshing();
33         void calc_meshing();
34
35         void update(float dt);
36         void draw() const;
37
38         Gear *intersect_gear(const Ray &ray, HitPoint *hitp = 0) const;
39 };
40
41 #endif  // MACHINE_H_