This example shows how to add per-point properties to a point cloud and access its properties.
27#include <easy3d/core/point_cloud.h>
28#include <easy3d/core/random.h>
29#include <easy3d/util/initializer.h>
39int main(
int argc,
char** argv) {
50 for (
int i=-5; i<5; ++i) {
51 for (
int j = -5; j < 5; ++j)
52 cloud->
add_vertex(
vec3(
static_cast<float>(i),
static_cast<float>(j), 0));
54 std::cout <<
"point cloud has " << cloud->n_vertices() <<
" points" << std::endl;
66 auto colors = cloud->add_vertex_property<
vec3>(
"v:color");
67 for (
auto v : cloud->vertices())
68 colors[v] = random_color();
75 auto points = cloud->get_vertex_property<
vec3>(
"v:point");
76 for (
auto v : cloud->vertices())
77 std::cout <<
"index: " << v.idx() <<
", xyz: " << points[v] <<
", color: " << colors[v] << std::endl;
A data structure for point clouds.
Definition point_cloud.h:45
Vertex add_vertex(const vec3 &p)
Add a new vertex with position p.
Definition point_cloud.cpp:177
Definition collider.cpp:182