Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions examples/coordarrows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> offset = {};
Expand All @@ -19,9 +25,11 @@ int main()
cavm->finalize();
v.addVisualModel (cavm);

sm::vec<float> ux = {1,0,0};
sm::vec<float> uy = {0,1,0};
sm::vec<float> 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<float>::ux(), etc to get static, constexpr unit vectors
constexpr sm::vec<float> ux = {1,0,0};
constexpr sm::vec<float> uy = {0,1,0};
constexpr sm::vec<float> uz = {0,0,1};

// An CoordArrows model, with non-defaults
offset[0] += 1.5f;
Expand Down
3 changes: 3 additions & 0 deletions mplot/VisualBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float, 3>& _lengths, const float _thickness = 1.0f)
{
this->coordArrows->lengths = _lengths;
this->coordArrows->thickness = _thickness;
this->coordArrows->clear();
this->coordArrows->initAxisLabels();
this->coordArrows->reinit();
}

Expand Down
Loading