From: John Tsiombikas Date: Sat, 17 Sep 2016 21:58:40 +0000 (+0300) Subject: move gears along their axis with the mousewheel X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=antikythera;a=commitdiff_plain;h=b29d7193d03833109cfdda3ab576fe183efd8acf move gears along their axis with the mousewheel --- diff --git a/src/gear.cc b/src/gear.cc index f6872cf..c916e76 100644 --- a/src/gear.cc +++ b/src/gear.cc @@ -48,6 +48,11 @@ void Gear::set_axis(const Vec3 &axis) xform_valid = false; } +const Vec3 &Gear::get_axis() const +{ + return axis; +} + void Gear::set_position(const Vec3 &pos) { this->pos = pos; diff --git a/src/gear.h b/src/gear.h index e8796e9..7f230e4 100644 --- a/src/gear.h +++ b/src/gear.h @@ -78,6 +78,7 @@ public: // of the gear, to achieve the required tooth pitch void set_teeth(int nt, float tooth_pitch); void set_axis(const Vec3 &axis); + const Vec3 &get_axis() const; void set_position(const Vec3 &pos); const Vec3 &get_position() const; Vec3 get_global_position() const; // taking parent gear into account diff --git a/src/main.cc b/src/main.cc index f98f190..ce8466e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -215,6 +215,14 @@ static void mouse(int bn, int st, int x, int y) sel_gear = 0; } } + + if(bidx == 3 || bidx == 4) { /* wheel */ + if(hover_gear) { + float dz = bidx == 4 ? 1 : -1; + hover_gear->set_position(hover_gear->get_position() + hover_gear->get_axis() * dz); + machine->invalidate_meshing(); + } + } } static void motion(int x, int y)