28 for (
size_t i = 0; i < N; i++)
48 for (
size_t i = 0; i < N; i++)
50 const double ang = i * 0.01;
51 TPoint3D pp =
p + up * 30 * cos(ang) +
lat * 30 * sin(ang);
52 gl->insertPoint(pp.
x, pp.
y, pp.
z);
61 for (
size_t i = 0; i < N; i++)
82 theScene->insert(gl_pointcloud);
84 gl_pointcloud->setPointSize(3.0);
85 gl_pointcloud->enablePointSmooth();
86 gl_pointcloud->enableColorFromZ();
92 cout <<
"Building point cloud...";
95 for (
int XX = -10; XX <= 10; XX++)
97 const double off_x = XX * 2 * L;
99 for (
int YY = -10; YY <= 10; YY++)
101 const double off_y = YY * 2 * L;
104 1e4, gl_pointcloud,
TPoint3D(off_x + 0, off_y + 0, 0),
105 TPoint3D(off_x + L, off_y + 0, 500));
108 1e4, gl_pointcloud,
TPoint3D(off_x + L, off_y + 0, 500),
109 TPoint3D(off_x + L, off_y + L, -500));
112 1e4, gl_pointcloud,
TPoint3D(off_x + L, off_y + L, -500),
113 TPoint3D(off_x + 0, off_y + L, 500));
116 1e4, gl_pointcloud,
TPoint3D(off_x + 0, off_y + L, 500),
124 printf(
"Point count: %e\n", (
double)gl_pointcloud->size());
129 gl_pointcloud->octree_get_graphics_boundingboxes(*gl_bb);
130 theScene->insert(gl_bb);
134 win.setCameraZoom(600);
137 view->setViewportClipDistances(0.1, 1e6);
141 win.unlockAccess3DScene();
144 cout <<
"Close the window or press any key to end.\n";
146 while (
win.isOpen() && !
end)
148 std::this_thread::sleep_for(5ms);
152 switch (
win.getPushedKey())
158 gl_bb->setVisibility(!gl_bb->isVisible());
165 "FPS=%5.02f | Rendered points=%.02e/%.02e (%.02f%%) | " 166 "Visib.oct.nodes: %u/%u",
167 win.getRenderingFPS(), (double)gl_pointcloud->getActuallyRendered(),
168 (double)gl_pointcloud->size(),
169 100 * double(gl_pointcloud->getActuallyRendered()) /
170 double(gl_pointcloud->size()),
171 (
unsigned int)gl_pointcloud->octree_get_visible_nodes(),
172 (
unsigned int)gl_pointcloud->octree_get_node_count());
174 win.get3DSceneAndLock();
178 5, 35,
"'b': switch bounding-boxes visible, 'q': quit",
180 win.unlockAccess3DScene();
194 std::this_thread::sleep_for(500ms);
198 catch (
const std::exception& e)
205 printf(
"Untyped exception!!");
void TestOctreeRenderHugePointCloud()
double drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.
double x
X,Y,Z coordinates.
void insertRandomPoints_gauss(const size_t N, opengl::CPointCloud::Ptr &gl, const TPoint3D &p_mean, const TPoint3D &p_stddevs)
static Ptr Create(Args &&... args)
double drawGaussian1D(const double mean, const double std)
Generate a normally distributed pseudo-random number.
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
This base provides a set of functions for maths stuff.
double lat
[deg], [deg], hgt over sea level[m]
mrpt::gui::CDisplayWindow3D::Ptr win
void insertRandomPoints_uniform(const size_t N, opengl::CPointCloud::Ptr &gl, const TPoint3D &p_min, const TPoint3D &p_max)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A RGB color - floats in the range [0,1].
The namespace for 3D scene representation and rendering.
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
Classes for creating GUI windows for 2D and 3D visualization.
void insertRandomPoints_screw(const size_t N, opengl::CPointCloud::Ptr &gl, const TPoint3D &p_start, const TPoint3D &p_end)
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.