6 #include "../core/log.h" 9 auto message = topic().message();
10 double radius = pointRadius();
11 _material->color().r() = color().r();
12 _material->color().g() = color().g();
13 _material->color().b() = color().b();
14 _material->opacity() = color().a();
16 node()->frame(message->header.frame_id);
18 if (_watcher.changed(message, radius)) {
21 auto projector = _projector;
23 std::make_shared<Mesh>([message, radius, projector]() {
25 sensor_msgs::PointCloud cloud;
26 projector->projectLaser(*message, cloud);
29 for (
auto &point : cloud.points) {
31 mesh.indices.push_back(mesh.positions.size() + 0);
32 mesh.indices.push_back(mesh.positions.size() + 1);
33 mesh.indices.push_back(mesh.positions.size() + 2);
35 mesh.indices.push_back(mesh.positions.size() + 0);
36 mesh.indices.push_back(mesh.positions.size() + 2);
37 mesh.indices.push_back(mesh.positions.size() + 3);
39 for (
size_t i = 0; i < 4; i++) {
40 mesh.positions.emplace_back(point.x, point.y, point.z);
43 Eigen::Vector4f extra(radius, radius, 1.0, 0.0);
44 mesh.extras.emplace_back(extra);
45 mesh.extras.emplace_back(extra);
46 mesh.extras.emplace_back(extra);
47 mesh.extras.emplace_back(extra);
49 mesh.texcoords.emplace_back(-1, -1);
50 mesh.texcoords.emplace_back(+1, -1);
51 mesh.texcoords.emplace_back(+1, +1);
52 mesh.texcoords.emplace_back(-1, +1);
59 _mesh_renderer.reset();
62 MeshDisplayBase::renderSync(context);