# How to Create a Mesh from Cloud Points

I have gone through the tutorial hereHow to create a Mesh and had no success in doing the following task.

I have a cloud points (x,y,z) file which has thousands of points. How do I plot those points in JME? How should I approach ?

I have the following code which creates a MESH in a point mode which draws point at each vertex. However, it is only drawing one point instead of 4. What could be the problem? With the sample example I was able to draw all four points! But not with my custom values. What am I missing in the code? please help!!! Thank you!

`pre type="java"`
Mesh m = new Mesh();

Vector3f [] vertices = new Vector3f[4];

vertices[0] = new Vector3f(26.354990f,40.326794f, 0);

vertices[1] = new Vector3f(36.938738f, 50.282257f, 10);

vertices[2] = new Vector3f(46.516779f, 60.237816f, -20);

vertices[3] = new Vector3f(56.126751f, 70.237816f, 30);

m.setBuffer(Type.Position, 3, ufferUtils.createFloatBuffer(vertices));

m.updateBound();

// Creating a geometry, and apply a single color material to it

Geometry geom = new Geometry(â€śOurMeshâ€ť, m);

m.setMode(Mesh.Mode.Points);

m.setPointSize(1f);

m.updateBound();

m.setStatic();

Material mat = new Material(assetManager, â€śCommon/MatDefs/Misc/Unshaded.j3mdâ€ť);

mat.setColor(â€śColorâ€ť, ColorRGBA.Green);

geom.setMaterial(mat);

// Attaching our geometry to the root node.

rootNode.attachChild(geom);
`/pre`

this may sound a tad silly but have you tried lowering those values? Itâ€™s not impossible that those values simply are not in the cameraâ€™s view, whereas the example keeps them at 0 to 1 everywhereâ€¦

Why not use a factor like 0.1f vor all those values?

Did you set the near clipping plane, far clipping plane and camera position accordingly?

Also: Be aware, that Float (EEE single floating point) only gives 6 to 7 decimal digits of precisionâ€¦

Instead of using Quad Mesh to draw the cloud points, I am now using BOX. Also, I have cloud points file with 2 Million+ points!!! The application hangs at just about 200k points!! Can JME handle these many points in some way? Here is my code

`pre type="java"`
//for every cloud point(vector). This is inside a for loop.

boxMesh = new Box(vector, 0.1f,0.1f,0.1f);

geometry = new Geometry(â€śsphereâ€ť, boxMesh);

geometry.setMaterial(solidColor);

geometry.setCullHint(CullHint.Dynamic);

rootNode.attachChild(geometry);
`/pre`

In the end, after the for loop I have

`pre type="java"`
cam.setLocation(new Vector3f(0, 0, -5));

cam.lookAtDirection(Vector3f.UNIT_Z, Vector3f.UNIT_Y);

cam.setFrustumFar(1000);
`/pre`

Is there a way to make JME run well with 2+ Million cloud points(Box) ?

Would you like me to implement an LOD-Viewer for your point cloud?

Seems like a good exercise.

It would be a combination of an LOD-graph and visualisation techniques.

Could you just give me the max(x,y,z) and min(x,y,z) ? then I will generate the points randomly for the test.

Ogli said:
Would you like me to implement an LOD-Viewer for your point cloud?
Seems like a good exercise.
It would be a combination of an LOD-graph and visualisation techniques.
Could you just give me the max(x,y,z) and min(x,y,z) ? then I will generate the points randomly for the test.

That is so nice of you!! Here are the MAX and MIN...
MAX(5.847956, 2.126556, 19.251)
MIN( -4.675392, -3.287754, 0.0)

Thanks!!!

Ok, I will report the progresses in this thread.

I was quite skilled with jME2, jME3 is a bit new to me.

So maybe it will take some days instead of hoursâ€¦

Here the first results:

PointCloudJme3GraphGenerator.java - interface

AbstractPointCloudGraphGenerator.java - implementation, part 1

RawPointCloudGraphGenerator.java - implementation, part 2

TestPointCloud.java - a simple test application (2 mio. random points)

Even with this very early brute force technique I get maximum framerate on my 2 year old machine.

I simply used point sprites - and the hardware culling speeds things up, as I have seen during the test.

Only thing that I struggled with, and could not fix yet: the points appear as semi transparent. I would have liked them to be totally opaque.

Also, they are currently squares, not circles. This is by design and could be fixed easily. There are two options for a fix: Write a simple shader with (uu + vv) > 1.0 = transparent, or simply use the particle material with a texture, that shows a circle. As I just said - both very simple ways to turn squares into circlesâ€¦

8)

5 Likes

Hm, no feedbackâ€¦

Seems there is no interest in point cloud visualisation anymore.

So there is no motivation for me to spend time on this.

Hope, the solution from my previous post helped anyoneâ€¦

bye

It has not been the task of the original poster to generate a particle system.

What he / she had in mind was the visualisation of a cloud of points with specific coordinates.

You can look at the posting before yours - I posted 3 classes / interfaces, and a simple testâ€¦

Since the particle system was lately extended by an influence system it would be no problem to implement that. In fact it really wasnâ€™t before.

The original poster could not accomplish it, so I helped out.

If there had been more interest, I would have continued with spatial partitioning and LOD.

The only reason my simple brute force test worked, is because there were â€śonlyâ€ť 2 million points to be rendered.

Iâ€™m late but this would be very useful for me, can I use it?

You might want to message @ogli directly, I doubt heâ€™ll notice a forum post nearly a year later

Hello kotoko and zarch:

Yes, the point cloud renderer is open-source with the same license like jME.

Feel yourself free to use it! (and even better: to modify it yourself)

3 Likes

I wouldnâ€™t mind testing any new developments with this codeâ€¦ sorry I wasnâ€™t here to appreciate your work here a few years ago Ogli.

If someone wanted to pick this up, it would certainly be a nice addition to the contribution repo

Ogli, what were your ideas for extending your LOD viewer? I am enjoying it.

Here are a few things I would like to get working:

• Point Size - on a per vertex basis - possibly calculated as a function of existing data or some other data.
• Animation - new data (position, color, pointsize) per frameâ€¦ or interpolation between keyframes, data deltas, or whatever.
• Other â€śtracks of dataâ€ť to be used on a per vertex basis (available to custom â€śrenderâ€ť callbacks, or made available to shaders)â€¦
• Support rendering 2d/3d textures in addition to vertex buffers.
• Grid System

axis, labels, coordinate tracking,

mouseover point descriptions (listener approachâ€¦ default behaviour do nothing)
• if data was denormalizedâ€¦ methods to convert points back to original data valuesâ€¦ i.e. pluggable functions.
• Data culling/volume probe â€“ like in the glman pointcloud demo.
• cutting planes/etc.

Some of this can be stuff can be pushed into shadersâ€¦ perhaps a flexible architecture to decide what is done whereâ€¦ Or just different implementationsâ€¦