diff --git a/examples/coordarrows.cpp b/examples/coordarrows.cpp index a53ee0ff..393f49e3 100644 --- a/examples/coordarrows.cpp +++ b/examples/coordarrows.cpp @@ -11,6 +11,12 @@ int main() mplot::Visual v(1024, 768, "Coordinate Arrows"); v.showCoordArrows (true); // Shows the 'scene' coordarrows, that you get in every mplot::Visual v.lightingEffects(true); + // You can update the coord arrows lengths and thickness scaling factor for the main CoordArrows + // if you want to. This updates to the defaults, and so is what you'd get if you left the call + // out: + v.updateCoordLengths ({ 0.1f, 0.1f, 0.1f }, 1.0f); + // This alternative makes the coordinate arrows longer: + // v.updateCoordLengths ({ 0.2f, 0.2f, 0.2f }, 1.0f); // An extra CoordArrows model, with defaults sm::vec offset = {}; @@ -19,9 +25,11 @@ int main() cavm->finalize(); v.addVisualModel (cavm); - sm::vec ux = {1,0,0}; - sm::vec uy = {0,1,0}; - sm::vec uz = {0,0,1}; + // I define some unit vectors here, because it makes the calls to CoordArrows::init easy to + // read, but you can also use sm::vec::ux(), etc to get static, constexpr unit vectors + constexpr sm::vec ux = {1,0,0}; + constexpr sm::vec uy = {0,1,0}; + constexpr sm::vec uz = {0,0,1}; // An CoordArrows model, with non-defaults offset[0] += 1.5f; diff --git a/mplot/VisualBase.h b/mplot/VisualBase.h index de7dff63..79e85206 100644 --- a/mplot/VisualBase.h +++ b/mplot/VisualBase.h @@ -397,10 +397,13 @@ namespace mplot this->coordArrows->reinit(); } + // Update the lengths of the CoordArrows that (usually) appear in the corner of the screen void updateCoordLengths (const sm::vec& _lengths, const float _thickness = 1.0f) { this->coordArrows->lengths = _lengths; this->coordArrows->thickness = _thickness; + this->coordArrows->clear(); + this->coordArrows->initAxisLabels(); this->coordArrows->reinit(); }