# How to create a point cloud?

Hi,
I have a set of 3D points and I would like to create it in my scene. I know how to create a dynamic mesh with vertex and face informations, but in the case of a point cloud, I have no information about the faces as there is no face.
So how to create a point cloud, with good performance of course ?
Thanks.

That is, are you trying to tessellate your point cloud?

2 ways of doing it as far as I know:

• custom mesh with point draw primitive
• I can give you a MDL file with 32k points. You can update their position when itâs needed. Iâm using it with Google Tango.

I think particlesâŚ

Is this a requirement for custom geometry?

You could create your own `PointCloud` component that is linked to custom geometry for drawing and has a `Vector<Vector3> data_`.

Thanks for your answers. So, no tessallation, I just display the set of points with no treatment on it. I think particles is a bit too much for my case as I donât need transformation on the points.
I finally did it like any other dynamic mesh, using VertexBuffer, IndexBuffer and Geometry, and indeed, face information is not a requirement.

1 Like

Could you provide a code example? I am trying to achieve an equal problem.

in kabucode:

for âa vector3â in âa lot of vectorsâ:
->change âvector3 intensityâ by ârandom somethingâ
->change âvector3 directionâ by ârandom somethingâ

you may want to set minimal scattering distance / harmonic function to avoid strange thingsâŚ

It would really help if you could provide code how to build up the vertexbuffer, how to fill it dynamically in the scene update and how you bind it through the CustomGeometry.

You may want to:

1. build an cloud of points thru some random / scattering technique
2. use a tessellation algorithm to obtain the external shape
3. pass the object to urho in a form it can understand

for 1) you can follow the previous kabucode I posted. Make a loop, take a point in space (vector3) and scatter it by its lenght (intensity) and direction (angle). Guess itâs in urho.math
for 2) I donât know if urho has a tessellation systemâŚ guess not. (maybe somewhere scattered in the forum thereâs an implementation). You may be confortable using a 3d party tessellation library. Thereâs a compact one here, yoctogl. Or you can try st like libigl, voro++, libtess2
for 3) I think you need to take all verts/edges/faces and create a static model or so. The process is roughly this:

``````    auto triangleMan = [&](){
// custom geometry

triangleNode = scene_->CreateChild("triangleNode");
CustomGeometry* cg = triangleNode->CreateComponent<CustomGeometry>();
cg->Clear();
cg->SetNumGeometries(1);
cg->BeginGeometry(0, PrimitiveType::TRIANGLE_LIST);
// TRIANGLE MAN!
// points are clockwise-ordered!
cg->DefineVertex(Vector3(-1,0,0));
cg->DefineColor(Color::GREEN);
cg->DefineVertex(Vector3(0,1,0));
cg->DefineColor(Color::RED);
cg->DefineVertex(Vector3(1,0,0));
cg->DefineColor(Color::BLUE);
Material* mat = new Material(context_);
auto teq = cache->GetResource<Technique>("Techniques/NoTextureUnlitVCol.xml");
mat->SetTechnique(0, teq);
cg->SetMaterial(mat);
mat->SetFillMode(FillMode::FILL_SOLID);
cg->Commit();
// center of screen, ortho 2d elevation
auto scp = camera->ScreenToWorldPoint(Vector3(0.5f,0.5f,-1));
triangleNode->SetPosition(scp);

};
``````

basicly if you can create a triangle you can create everything. You only need to feed all items in the right orderâŚ
In custom geometry you only need to pass pointsâŚ if you pass them in the correct order, edges and faces are made for youâŚ so theorically you could skip tessellation if you follow the route correctly and build everything euclideanâŚ
But given what you want you probably are better fit with a ânormalâ urho geometry objectâŚ but this is your skill

(p.s.) moreover, thereâs iogram, a tool based on urho for building live geometryâŚ

Thy for your answer, okay i think i have another problem i understand creating the CustomGeometry now. But i have large NEW pointclouds in each sceneupdate, which i need to add to the scene graph ~ 40 k points. This data is put into a std::vector from a library containing vertices, normals and color as float values. So i donât want to call ->DefineVertex(), etcâŚ for each point. I want to use something like VertexElements to tell urho how my data struct is build and then bind new data via indices directly through the VertexBuffer of the âGeometryâ which is basically just a List for PointPrimitives.

No Meshing, no tesselation. ;D

Only other thing I remember is A Mesh Generator
but probably thatâs just what the solution above will do.