X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=antikythera;a=blobdiff_plain;f=src%2Fgear.h;h=281e77f2d19e62800656c3f20e9d607ed13e6a9c;hp=5fde21fefaa2efc0dad8ddc8ec683f65b3f987ab;hb=84484521a697fe60f63bff077b9ba7475a45e54e;hpb=ae60a8cb1a30e204e7f60969fe6245e510cca0ff diff --git a/src/gear.h b/src/gear.h index 5fde21f..281e77f 100644 --- a/src/gear.h +++ b/src/gear.h @@ -2,6 +2,7 @@ #define GEAR_H_ #include +#include #include #include "mesh.h" @@ -38,24 +39,31 @@ class Gear { private: Mesh *mesh; - mutable Mat4 xform; + mutable Mat4 xform, dir_xform; + mutable bool xform_valid; void calc_matrix() const; float contour(float u); public: - Vec3 pos, axis; /* implicitly defines a plane eqn. */ - float pdist; /* derived: distance of plane from origin */ - float angle; /* current angle of the gear */ + /* TODO hide most of this shit, especially the stuff which invalidate + * the transformation matrices + */ + std::string name; + Vec3 pos, axis; // implicitly defines a plane eqn. + float pdist; // derived: distance of plane from origin - int nteeth; /* number of teeth */ + float init_angle; // initial starting angle + float angle; // current angle of the gear - float radius; /* total radius of the gear, including teeth */ - float teeth_length; /* how far teeth extend past the radius */ - float thickness; /* thickness of the gear along the Z axis */ + int nteeth; // number of teeth - float bevel; /* bevel size */ + float radius; // total radius of the gear, including teeth + float teeth_length; // how far teeth extend past the radius + float thickness; // thickness of the gear along the Z axis + + float bevel; // bevel size std::vector pins; std::vector slots; @@ -63,6 +71,24 @@ public: Gear(); ~Gear(); + // sets the supplied number of teeth, and calculates the radius + // of the gear, to achieve the required tooth pitch + void set_teeth(int nt, float tooth_pitch); + void set_axis(const Vec3 &axis); + void set_position(const Vec3 &pos); + const Vec3 &get_position() const; + Vec3 get_global_position() const; // taking parent gear into account + + void set_angle(float angle); + float get_angle() const; + + float get_vis_rotation() const; + const Mat4 &get_matrix() const; + const Mat4 &get_dir_matrix() const; + + // returns the angle (in radians) from one tooth to the next + float get_angular_pitch() const; + void draw() const; bool gen_mesh();