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