2

I have a data set which compromises of the order of a million cuboids. I render it as a single node, using TriangleMesh. This seems OK, rotation is fast. But I also want to do slicing of it, so I implemented code to recalculate the faces and apply these. It works, but is a bit slow - not in calculating the faces indices, but it seems in the rendering.

Each cuboid consists of 12 triangles

I then tried it with having a separate node for each cuboid, and setting the nodes visible/invisible. Performance of this was horrible.

Any ideas? To get an idea of what I am talking about, take a look at

http://www.peclouds.com/node/1

José Pereda
  • 44,311
  • 7
  • 104
  • 132

1 Answers1

1

Do you know the FXyz library? It has several new 3D complex shapes, along with complex texturing options, to enable contour plots, for instance.

Have a look also at the Sampler, to explore all of the options.

Some of the lastest (uncommitted) developments in the library are ScatterMesh and TetrahedraMesh.

We can read data from files, with every line containing {x,y,z,f} data, and create a tetrahedron for that point (x,y,z), using only 4 triangles (4 points and 4 faces). And we set the density color according to f.

We can add every tetrahedron as a node, and have a full group of nodes, which is only valid for small number of nodes, or we could create one single mesh, as you said, by adding every new tetrahedron to this mesh. That is really fast, and I've managed to read several millions of data points.

This mesh has 1 million of tetrahedra, or 4 million of triangles:

Scatter 1M

For now we don't have a slicing algorithm. You are welcome to contribute with it.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Thank you Jose. I was aware of Fxyz, but have not looked closely at it. You seem to confirm my findings that a single large mesh has better performance that a large number of nodes each with a small mesh. – Nigel Goodwin Jul 25 '15 at 22:47
  • I am also wondering whether points are best defined as normal or not. My points are fixed once defined, but my faces have a lot of user interaction. – Nigel Goodwin Jul 25 '15 at 22:50
  • What kind of interaction? Meshes now support normals, but in FXyz we haven't used them (yet). – José Pereda Jul 25 '15 at 22:52
  • In simple terms (the reality is more complex!), imagine a grid of a million cuboids, and then you want to see some slices, for example show all cuboids with I = 5, 10, 15 or j = 9, 12, 16 – Nigel Goodwin Jul 25 '15 at 23:39
  • The slices are defined interactively with a dual slider, and it should be smooth as the slider is changed....currently as the slider changes, I recalculate the faces and then do an addAll. Recaluclating is fast, but there is a pause during the addAll, presumably because it has to do a lot of calculating/rendering. Basically I am making faces visible/invisible, by recalculating all the faces. In this was you can look inside the 3D picture. The 3D is of an oil/gas reservoir model. Most implementors use C++ libraries, but I'm a Java person. – Nigel Goodwin Jul 25 '15 at 23:40
  • See the video I mention in my original question for an example, which uses OpenSceneGraph. I guess for any solid 3d body you want to be able to look 'inside' in various flexible ways. – Nigel Goodwin Jul 25 '15 at 23:47
  • Without having a look at your code I can't really tell, but definitely, if points are fixed, recalculating faces only should be fast, and redrawing shouldn't take long. I've used this technique to create animated density plots. – José Pereda Jul 25 '15 at 23:47
  • OK thanks. So what I am doing is probably already the best approach, and I'm not missing anything. I will look into making it more intelligent, by considering more which internal faces will not be visible whatever the rotation. In simple terms, when displaying the full reservoir, only the outside faces are visible. Can you point to an example of your animated density plots? I have downloaded most of the FXyz code. – Nigel Goodwin Jul 26 '15 at 00:11
  • Have a look at this [video](https://www.youtube.com/watch?v=CMGQrcm8RV0). Also you can check my post [here](http://jperedadnr.blogspot.com/2015/01/creating-and-texturing-javafx-3d-shapes.html). – José Pereda Jul 26 '15 at 11:05
  • I've put a lot more intelligence into which faces are visible (i.e. not ones which are surrounded by other cubes) and it works MUCH faster. 0.5 million cubes (so 8 million points or 6 million triangles in total) is not a problem, even on a laptop. Of course, much more scope for optimising using multiple threads and Java 8, as you have found. – Nigel Goodwin Jul 28 '15 at 16:27