@@ -27,11 +27,12 @@ int main (int argc, char** argv)
2727 eyefile = std::string (argv[1 ]);
2828 }
2929
30+ // Compound eyes are tiny. We make them larger in our scene by this factor
31+ constexpr float eye_scaleup = 1000 .0f ;
32+
3033 float psrad = 0 .5f ;
3134 if (argc > 2 ) { psrad = std::atof (argv[2 ]); }
3235
33- auto v = mplot::Visual<>(1024 , 768 , " mplot::compoundray::EyeVisual" );
34-
3536 // We read the information from the eye file into a vector of Ommatidium objects. Ommatidium is
3637 // defined in "cameras/CompoundEyeDataTypes.h" in compound ray, mplot::Ommatidium is a
3738 // mplot/Seb's maths style equivalent. It contains 2 3D float vectors and two scalar floating point
@@ -43,6 +44,18 @@ int main (int argc, char** argv)
4344 // using it, but for this example we instead make use of mplot::compoundray::readEye
4445 if (mplot::compoundray::readEye (ommatidia.get (), eyefile) == nullptr ) { std::cout << " Failed to read eye\n " ; return -1 ; }
4546
47+ sm::range<sm::vec<float >> ommspan = sm::range<sm::vec<float >>::search_initialized ();
48+ // Use the eye spacing to control the size of the coord arrows
49+ for (auto omm : *ommatidia.get ()) {
50+ // omm is an Ommatidium. Want to know the x, y and z spans
51+ ommspan.update (omm.relativePosition );
52+ }
53+ float ca_len = eye_scaleup * ommspan.span ().max () / 3 .0f ;
54+ auto v = mplot::Visual<>(1024 , 768 , " mplot::compoundray::EyeVisual" );
55+ v.showCoordArrows (true );
56+ v.coordArrowsInScene (true );
57+ v.updateCoordLengths ({ ca_len, ca_len, ca_len }, 1 .0f );
58+
4659 // Make some dummy data to demo the eye
4760 sm::vvec<float > ommatidiaData;
4861 ommatidiaData.linspace (0 , 1 , ommatidia->size ());
@@ -70,7 +83,7 @@ int main (int argc, char** argv)
7083
7184 [[maybe_unused]] auto ep = v.addVisualModel (eyevm);
7285 // ep->reinitColours();
73- ep->scaleViewMatrix (1000 . 0f );
86+ ep->scaleViewMatrix (eye_scaleup );
7487
7588 v.keepOpen ();
7689}
0 commit comments