Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
ec13858
Create NavMesh.h and make associated changes
sebsjames Oct 23, 2025
9c65fe1
More navigation code
sebsjames Oct 23, 2025
126e998
Removes debug code
sebsjames Oct 23, 2025
af79bbc
Refactoring
sebsjames Oct 23, 2025
bf42ebd
Copy the BB into navmesh (and compute it if necessary)
sebsjames Oct 23, 2025
d763631
Minor, removed some debug logging
sebsjames Oct 23, 2025
81c6a7e
Some work in progress debugging initial placement of the camera.
sebsjames Oct 24, 2025
4c0f31f
Haven't got to the bottom of placing the camera frame on a non-unifor…
sebsjames Oct 24, 2025
ecd0c3d
Refactoring my current best guess at the right transformation
sebsjames Oct 24, 2025
7c96f52
Position camera is ok, the problem now is the camera frame after a mo…
sebsjames Oct 25, 2025
7cdf3de
Just typos
sebsjames Oct 25, 2025
32de0ca
Thinking about a fix staying in model frame, but keeping camera frame…
sebsjames Nov 3, 2025
1f96041
Convert triangles to scene frame before recomputing camera movement
sebsjames Nov 3, 2025
8768eb6
Update maths
sebsjames Nov 3, 2025
e7022e9
Disable cubetrans prog for MacOS as it is foxing the github runners
sebsjames Nov 3, 2025
dcf9f1c
Usage help on cmd line for triangle_intersect
sebsjames Nov 3, 2025
b588d8a
Improving error handling
sebsjames Nov 4, 2025
9f3b03d
Passing triangles back in exceptions to aid debug
sebsjames Nov 4, 2025
648a31c
Code to detect if a movement takes us up to and edge triangle. We'll …
sebsjames Nov 5, 2025
747034e
Changes to NavException
sebsjames Nov 6, 2025
9ce6b5d
WIP
sebsjames Nov 7, 2025
c2a90f9
WIP
sebsjames Nov 7, 2025
9565d0f
bloomin boundaries
sebsjames Nov 7, 2025
98af1b6
Make an assumption here, which holds quite well, now only need to han…
sebsjames Nov 8, 2025
3c8fca9
Saturday WIP
sebsjames Nov 10, 2025
4bdcb14
Monday progress. Getting right down to corner cases now (passing over…
sebsjames Nov 10, 2025
769f028
Tuesday bug fixing - getting close now
sebsjames Nov 11, 2025
f4b744c
Use de
sebsjames Nov 12, 2025
057f0eb
Avoid a clang error
sebsjames Nov 12, 2025
0a79775
Debug
sebsjames Nov 12, 2025
d6c9444
WIP thinking about optimizing this process
sebsjames Nov 12, 2025
783a181
Not sure if this is going to be faster or not
sebsjames Nov 12, 2025
2fe2fa1
Broken WIP
sebsjames Nov 12, 2025
58e4d64
Speed up in tri mesh simplification using unordered map, also switch …
sebsjames Nov 13, 2025
40f8755
Updates maths to main branch
sebsjames Nov 13, 2025
b94df92
Resolves what to do when we get to the edge of a model
sebsjames Nov 13, 2025
1d9cc22
Some stale code needed updating
sebsjames Nov 13, 2025
ca256c1
Removes some code that was really for debugging, and brought in an HD…
optseb Nov 14, 2025
a781b98
Wasn't much of a test, anyway
sebsjames Nov 14, 2025
9be3720
Warn user if set_cone_length will do nothing
sebsjames Nov 14, 2025
5f5b448
Adds a scaling function
sebsjames Nov 14, 2025
8183e1b
Adds an ellipsoid primitive
sebsjames Nov 17, 2025
744796f
Clang on MacOS 14 doesn't want to make an implicit move constructor
sebsjames Nov 17, 2025
6e96227
Adds a 'clear visual models' function
sebsjames Nov 18, 2025
e080f62
Improves scroll-wheel behaviour (fixing a bug)
sebsjames Nov 18, 2025
cc75498
Better translation when zoomed close to a selected model
sebsjames Nov 18, 2025
f9d63fb
Use latest maths
sebsjames Nov 19, 2025
f5164fc
Removes some ifdeffed out code
sebsjames Nov 19, 2025
8ec410d
WIP towards a flag compound ray eye representation
sebsjames Nov 20, 2025
92671b4
More WIP
sebsjames Nov 21, 2025
aa31435
runtime radius modification
sebsjames Nov 21, 2025
3e75dd0
WIP towards a 2D compound ray projections
sebsjames Nov 21, 2025
915c782
puts rays and sphere inside EyeVisual. reinitColours needs work
sebsjames Nov 21, 2025
de7e46a
Working towards multiple projections
sebsjames Nov 22, 2025
3c4df19
Bug fix. Works for one projection; not so well for two
sebsjames Nov 22, 2025
faaa791
Debugging, not progress
sebsjames Nov 24, 2025
369fd45
Some progress, moving to laptop
sebsjames Nov 24, 2025
ea4836c
Sorted
sebsjames Nov 24, 2025
8c83ace
Tidy up before defining ranges of ommatidia to show for a projection
sebsjames Nov 24, 2025
ce4628d
Now have a portion of each projection showing. Quite neat
sebsjames Nov 24, 2025
85e93a9
Bug fix on reinitColours for multiple projections
sebsjames Nov 25, 2025
bbf1bb0
Prepare to be able to do cylindrical projections
sebsjames Nov 25, 2025
9554cca
WIP on spherical projection displays
sebsjames Nov 25, 2025
578ccec
A spherical projection visual
sebsjames Nov 25, 2025
85e9be2
Adds spherical projections to healpix.cpp
sebsjames Nov 26, 2025
a77bd58
Corrections to spherical projections
sebsjames Nov 26, 2025
013d36e
WIP on coord systems
sebsjames Nov 26, 2025
fea1e79
Shows xyz directions on the healpix and on the projections
sebsjames Nov 26, 2025
b1a2ba5
Healpix and 2D projections are good.
sebsjames Nov 27, 2025
1af90cd
Just whitespace
sebsjames Nov 27, 2025
717a762
Latest maths
sebsjames Nov 27, 2025
393a766
Switch to main maths
sebsjames Nov 27, 2025
eee4438
Changed API in sm::maths
sebsjames Nov 27, 2025
5371a98
Changed API in sm::maths
sebsjames Nov 27, 2025
090a60b
Some more C++-ification
sebsjames Nov 28, 2025
3dca72b
It's necessary to use double precision in jcvoronoi to avoid bugs
sebsjames Nov 28, 2025
f737150
Corrected rotation of coords for CompoundRay
sebsjames Nov 29, 2025
a63aa2c
More C++ification of jc_voronoi
sebsjames Nov 29, 2025
c241a50
Pull some more API into the jc::voronoi class
sebsjames Nov 29, 2025
756baee
Get everything building with the new voronoi scheme
sebsjames Nov 29, 2025
275d20a
Stage 1 refactoring. T and jcv_edge
sebsjames Nov 29, 2025
e926fa8
More refcatoring
sebsjames Nov 29, 2025
8caf065
Completes refactoring
sebsjames Nov 29, 2025
e5d7104
diagram should just be a nonpointer member
sebsjames Nov 29, 2025
3d6db8f
Adds the loop sanity count to avoid getting bitten in the future
sebsjames Nov 29, 2025
861513c
Merge branch 'dev/flat_cray' of github.com:sebsjames/mathplot into de…
sebsjames Dec 1, 2025
3523855
Enforce house style
sebsjames Dec 1, 2025
b550b4d
Restore original about message
sebsjames Dec 1, 2025
4e08d06
Restore changes in SphereVisual
sebsjames Dec 1, 2025
93db686
Tidyup
sebsjames Dec 1, 2025
9043a33
Merge pull request #86 from sebsjames/dev/flat_cray
sebsjames Dec 1, 2025
d596927
Bring in line with changes in main
sebsjames Dec 1, 2025
4e70a96
Removes an unused variable
sebsjames Dec 1, 2025
f9d6619
Bring in the reflections code
sebsjames Dec 3, 2025
f09fd9f
Some EyeVisual WIP
sebsjames Dec 3, 2025
ae2cfbd
Adds crawler example and puts tn0/ti0 into NavMesh as state
sebsjames Dec 4, 2025
298a2cf
WIP on the crawler.
sebsjames Dec 4, 2025
9059cd4
Some WIP
sebsjames Dec 5, 2025
16aee9a
Adds logic to deal with special case that the start is ON a vertex, m…
sebsjames Dec 5, 2025
fbac12d
More WIP - nearly got this working
sebsjames Dec 5, 2025
b226e47
Removes probably blind-alley one-neighbours test code
sebsjames Dec 5, 2025
f0291d7
Another fix
sebsjames Dec 5, 2025
5e8e54e
Debug reduction
sebsjames Dec 5, 2025
6732d20
Use maths main
sebsjames Dec 5, 2025
98a163a
Merge pull request #88 from sebsjames/dev/crawler_example
sebsjames Dec 5, 2025
3d51be1
WIP
sebsjames Dec 5, 2025
1d611a2
Tweaks
sebsjames Dec 5, 2025
cd17a7d
Remove disc_width as user-option. Tidy up
sebsjames Dec 7, 2025
363ece0
Merge pull request #92 from sebsjames/dev/eyevisual
sebsjames Dec 7, 2025
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
26 changes: 21 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ if(NOT APPLE)
target_link_libraries(sphere OpenGL::GL glfw Freetype::Freetype)
endif()

add_executable(ellipsoid ellipsoid.cpp)
target_link_libraries(ellipsoid OpenGL::GL glfw Freetype::Freetype)

# constexpr code won't work on Apple Clang
if(NOT APPLE)
add_executable(icosahedron icosahedron.cpp)
Expand All @@ -377,6 +380,9 @@ if(NOT APPLE)
target_link_libraries(geodesic_ce OpenGL::GL glfw Freetype::Freetype)
endif()

add_executable(model_crawler model_crawler.cpp)
target_link_libraries(model_crawler OpenGL::GL glfw Freetype::Freetype)

add_executable(tri tri.cpp)
target_link_libraries(tri OpenGL::GL glfw Freetype::Freetype)

Expand All @@ -386,6 +392,9 @@ target_link_libraries(draw_triangles OpenGL::GL glfw Freetype::Freetype)
add_executable(draw_triangles_intersections draw_triangles_intersections.cpp)
target_link_libraries(draw_triangles_intersections OpenGL::GL glfw Freetype::Freetype)

add_executable(triangle_intersect triangle_intersect.cpp)
target_link_libraries(triangle_intersect OpenGL::GL glfw Freetype::Freetype)

add_executable(voronoi_random voronoi_random.cpp)
target_link_libraries(voronoi_random OpenGL::GL glfw Freetype::Freetype)

Expand Down Expand Up @@ -425,11 +434,14 @@ target_link_libraries(rhombo_scene2 OpenGL::GL glfw Freetype::Freetype)
add_executable(cube cube.cpp)
target_link_libraries(cube OpenGL::GL glfw Freetype::Freetype)

if(Eigen3_FOUND)
add_executable(cubetrans cubetrans.cpp)
target_include_directories (cubetrans BEFORE PRIVATE ${EIGEN3_INCLUDE_DIR})
target_link_libraries(cubetrans OpenGL::GL glfw Freetype::Freetype)
endif(Eigen3_FOUND)
# Eigen finding is not reliable on Github Mac OS runners
if(NOT APPLE)
if(Eigen3_FOUND)
add_executable(cubetrans cubetrans.cpp)
target_include_directories (cubetrans BEFORE PRIVATE ${EIGEN3_INCLUDE_DIR})
target_link_libraries(cubetrans OpenGL::GL glfw Freetype::Freetype)
endif(Eigen3_FOUND)
endif()

add_executable(cubetrans2 cubetrans2.cpp)
target_link_libraries(cubetrans2 OpenGL::GL glfw Freetype::Freetype)
Expand Down Expand Up @@ -529,3 +541,7 @@ endif()

add_executable(show_boundingboxes show_boundingboxes.cpp)
target_link_libraries(show_boundingboxes OpenGL::GL glfw Freetype::Freetype)

# if have compound-ray header
add_executable(cray_eye cray_eye.cpp)
target_link_libraries(cray_eye OpenGL::GL glfw Freetype::Freetype)
76 changes: 76 additions & 0 deletions examples/cray_eye.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* A compound ray eye viewer
*
* Demonstrating use of mplot::compoundray::EyeVisual
*/

#include <iostream>
#include <string>
#include <memory>

#include <sm/vec>
#include <sm/vvec>

#include <mplot/Visual.h>
#include <mplot/ColourMap.h>
#include <mplot/SphereVisual.h>
#include <mplot/VectorVisual.h>
#include <mplot/compoundray/EyeVisual.h>

int main (int argc, char** argv)
{
std::string eyefile = "";
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " path/to/eyefile.eye [projection sphere radius]\n";
return -1;
} else {
eyefile = std::string (argv[1]);
}

float psrad = 0.5f;
if (argc > 2) { psrad = std::atof (argv[2]); }

auto v = mplot::Visual<>(1024, 768, "mplot::compoundray::EyeVisual");

// We read the information from the eye file into a vector of Ommatidium objects. Ommatidium is
// defined in "cameras/CompoundEyeDataTypes.h" in compound ray, mplot::Ommatidium is a
// mplot/Seb's maths style equivalent. It contains 2 3D float vectors and two scalar floating point
// values.
auto ommatidia = std::make_unique<std::vector<mplot::compoundray::Ommatidium>>();
std::vector<std::array<float, 3>> ommatidiaColours;

// Read the eye file into ommatidia data structure. compound ray does this internally when we're
// using it, but for this example we instead make use of mplot::compoundray::readEye
if (mplot::compoundray::readEye (ommatidia.get(), eyefile) == nullptr) { std::cout << "Failed to read eye\n"; return -1; }

// Make some dummy data to demo the eye
sm::vvec<float> ommatidiaData;
ommatidiaData.linspace (0, 1, ommatidia->size());
// Colour it with a colour map
mplot::ColourMap cm (mplot::ColourMapType::Plasma);
ommatidiaColours.resize (ommatidia->size());
for (size_t i = 0; i < ommatidia->size(); ++i) {
ommatidiaColours[i] = cm.convert (ommatidiaData[i]);
}

auto eyevm = std::make_unique<mplot::compoundray::EyeVisual<>> (sm::vec<>{}, &ommatidiaColours, ommatidia.get());
v.bindmodel (eyevm);
eyevm->name = "CompoundRay Eye";
eyevm->show_cones = true;

auto ptype = mplot::compoundray::EyeVisual<>::projection_type::equirectangular; // mercator, equirectangular or cassini
sm::vec<> centre = { 0, 0, 0 };
sm::mat44<float> twod_tr;
twod_tr.translate (sm::vec<>{0,0,-0.1});
eyevm->add_spherical_projection (ptype, twod_tr, centre, psrad);
eyevm->pre_set_cone_length (4e-6f);
eyevm->show_sphere = true;
eyevm->show_rays = false;
eyevm->finalize();

[[maybe_unused]] auto ep = v.addVisualModel (eyevm);
// ep->reinitColours();
ep->scaleViewMatrix (1000.0f);

v.keepOpen();
}
52 changes: 38 additions & 14 deletions examples/draw_triangles_intersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ int main()
sm::vec<> start = { 2, 0, 5 };
sm::vec<> dirn = { 0, 0, -10 };

sm::vec<> start_fr2 = { 1, .9, 5 };
sm::vec<> dirn_fr2 = { 0.5, -0.7, -10 };

sm::vec<> start_bh = { 0, 0, -5 };
sm::vec<> dirn_bh = { 1.5, 1.5, 10 };

Expand All @@ -281,6 +284,11 @@ int main()
sv->finalize();
v.addVisualModel (sv);

sv = std::make_unique<mplot::SphereVisual<>>(start_fr2, 0.1, mplot::colour::goldenrod3);
v.bindmodel (sv);
sv->finalize();
v.addVisualModel (sv);

auto vvm = std::make_unique<mplot::VectorVisual<float, 3>>(start);
v.bindmodel (vvm);
vvm->thevec = dirn;
Expand All @@ -305,14 +313,26 @@ int main()
vvm->finalize();
[[maybe_unused]] auto vvmp2 = v.addVisualModel (vvm);

tvp->vertex_postprocess();
vvm = std::make_unique<mplot::VectorVisual<float, 3>>(start_fr2);
v.bindmodel (vvm);
vvm->thevec = dirn_fr2;
vvm->vgoes = VectorGoes::FromOrigin;
vvm->thickness = 0.02f;
vvm->arrowhead_prop = 0.1f;
vvm->fixed_colour = true;
vvm->single_colour = mplot::colour::crimson;
vvm->addLabel ("Ray from front through middle", {-0.8, -0.5, 0}, mplot::TextFeatures(0.1f));
vvm->finalize();
[[maybe_unused]] auto vvmp3 = v.addVisualModel (vvm);

tvp->make_navmesh();

auto vm = tvp->getViewMatrix();
auto vmi = vm.inverse();

auto start_wr = (vmi * start).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit, ti, tn] = tvp->find_triangle_crossing (start_wr, dirn);
auto [hit, ti, tn] = tvp->navmesh->find_triangle_crossing (start_wr, dirn);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
Expand All @@ -325,9 +345,23 @@ int main()
v.addVisualModel (sv);
}

auto start_wr_fr2 = (vmi * start_fr2).less_one_dim(); // wr to tvp
auto [hit_fr2, ti_fr2, tn_fr2] = tvp->navmesh->find_triangle_crossing (start_wr_fr2, dirn_fr2);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti_fr2[0] << "," << ti_fr2[1] << "," << ti_fr2[2] << std::endl;
std::cout << "Contains hit " << hit_fr2 << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit_fr2, 0.07, mplot::colour::springgreen2);
v.bindmodel (sv);
sv->finalize();
v.addVisualModel (sv);
}

auto start_wr_bh = (vmi * start_bh).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit_bh, ti_bh, tn_bh] = tvp->find_triangle_crossing (start_wr_bh, dirn_bh);
auto [hit_bh, ti_bh, tn_bh] = tvp->navmesh->find_triangle_crossing (start_wr_bh, dirn_bh);
if (ti_bh[0] == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
Expand All @@ -339,17 +373,7 @@ int main()
sv->finalize();
v.addVisualModel (sv);
}
#if 0
auto dtv = std::make_unique<doubletrivis<>>(sm::vec<float>{3.0f,0.0f,0.0f});
v.bindmodel (dtv);
dtv->finalize();
v.addVisualModel (dtv);

auto tctv = std::make_unique<twocolourtri<>>(sm::vec<float>{6.0f,0.0f,0.0f});
v.bindmodel (tctv);
tctv->finalize();
v.addVisualModel (tctv);
#endif

v.keepOpen();
return 0;
}
55 changes: 55 additions & 0 deletions examples/ellipsoid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Visualize an ellipsoid
*/
#include <iostream>
#include <stdexcept>
#include <string>
#include <sstream>

#include <sm/vec>

#include <mplot/Visual.h>
#include <mplot/VisualModel.h>
#include <mplot/colour.h>
#include <mplot/NormalsVisual.h>

// Quick visual that simply draws ellipsoid
template <int glver = mplot::gl::version_4_1>
class PrimitiveVisual : public mplot::VisualModel<glver>
{
public:
PrimitiveVisual (const sm::vec<float> _offset) { this->viewmatrix.translate (_offset); }

void initializeVertices()
{
sm::mat44<float> tr;
tr.rotate (sm::vec<>::uz(), sm::mathconst<float>::pi_over_4);
this->computeEllipsoid (sm::vec<float>{0},
mplot::colour::royalblue,
mplot::colour::maroon3,
sm::vec<float>{1,2,3},
40, 40, tr);
}
};

int main()
{
mplot::Visual v(1024, 768, "Ellipsoid primitive");
v.lightingEffects (true);

auto pvm = std::make_unique<PrimitiveVisual<>> (sm::vec<>{});
v.bindmodel (pvm);
pvm->finalize();
auto pvmp = v.addVisualModel (pvm);

constexpr bool show_normals = true;
if constexpr (show_normals) {
// Create an associate normals model
auto nrm = std::make_unique<mplot::NormalsVisual<>> (pvmp);
v.bindmodel (nrm);
nrm->finalize();
v.addVisualModel (nrm);
}

v.keepOpen();
}
2 changes: 0 additions & 2 deletions examples/geodesic_with_normals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ int main()
gv1p->data.linspace (0.0f, 1+i * imax_mult, sz1);
gv1p->reinitColours();

gv1p->vertex_postprocess(); // creates the triangles and normals required for NormalsVisual

// Create an associate normals model
auto nrm = std::make_unique<mplot::NormalsVisual<>> (gv1p);
v.bindmodel (nrm);
Expand Down
Loading
Loading