-1

I would like to implement a Maya plugin (this question is independent from Maya) to create 3D Voronoi patterns, Something like

enter image description here

I just know that I have to start from point sampling (I implemented the adaptive poisson sampling algorithm described in this paper).

I thought that, from those points, I should create the 3D wire of the mesh applying Voronoi but the result was something different from what I expected.

Here are a few example of what I get handling the result i get from scipy.spatial.Voronoi like this (as suggested here):

vor = Voronoi(points)
for vpair in vor.ridge_vertices:
    for i in range(len(vpair) - 1):
        if all(x >= 0 for x in vpair):
            v0 = vor.vertices[vpair[i]]
            v1 = vor.vertices[vpair[i+1]]
            create_line(v0.tolist(), v1.tolist())

The grey vertices are the sampled points (the original shape was a simple sphere): enter image description here

Here is a more complex shape (an arm) enter image description here

I am missing something? Can anyone suggest the proper pipeline and algorithms I have to implement to create such patterns?

Community
  • 1
  • 1
Jiloc
  • 3,338
  • 3
  • 24
  • 38
  • Isn't it a python question and/or mathematic question? – Micromega Oct 22 '15 at 11:11
  • I am not asking about an implementation, but about the pipeline I have to follow to get a mesh like those. I don't care about the language, I am just asking about the steps I have to follow. Something like: sample points -> apply this algorithm to get this output -> use it as input for Voronoi -> handle voronoi result like that to get this mesh. – Jiloc Oct 22 '15 at 11:20
  • How voronoi-diagram works is simple, do you know? – Micromega Oct 22 '15 at 11:21
  • I know how it works, I don't know if I am missing any step to get a mesh like this. – Jiloc Oct 22 '15 at 11:23
  • I am asking here in stackoverflow because there a lot of questions about Voronoi, more than in every other stackexchange's community! – Jiloc Oct 22 '15 at 11:24
  • Asking where? Try a simplier solution (2d) but IMO this is a more language thing. – Micromega Oct 22 '15 at 11:26
  • With 2D I can just do something like described [here](http://stackoverflow.com/questions/23658776/voronoi-diagram-edges-how-to-get-edges-in-the-form-point1-point2-from-a-scip) – Jiloc Oct 22 '15 at 11:30
  • So, it works? You can try 3d again, or another language/library? Can you do that? – Micromega Oct 22 '15 at 11:31
  • Yup as the image you see in the question I linked. But with 3D not only it doesn't work as expected, but the Voronoi result must be handled differently to get a mesh like those I showed in the question! I would be happy to change any library, language or write my own implementation if I only knew what I am missing, what I am doing wrong or what algorithm I should implement! – Jiloc Oct 22 '15 at 11:36
  • Just a question but do you need a visualisation? From the question your example result is totally wrong and the wanted image shows only a part of the 3d voronoi diagram (it is a constrained polygon)? I don't know python/lib but I doubt it can do it. Try cgal (I don't know either). – Micromega Oct 22 '15 at 11:42
  • I need the data, in whichever format it is, to create a mesh like those i showed. I will handle the visualization in a second step. Yup my result from the Voronoi(points) is totally wrong (or maybe I am just handling the result in a wrong way). Thank you for the suggestion I will check it out! – Jiloc Oct 22 '15 at 11:50

1 Answers1

1

I saw your question since you posted it but didn’t have a real answer for you, however as I see you still didn’t get any response I’ll at least write down some ideas from me. Unfortunately it’s still not a full solution for your problem.

For me it seems you’re mixing few separate problems in this question so it would help to break it down to few pieces:

Voronoi diagram:

The diagram is by definition infinite, so when you draw it directly you should expect a similar mess you’ve got on your second image, so this seems fine. I don’t know how the SciPy does that, but the implementation I’ve used flagged some edge ends as ‘infinite’ and provided me the edges direction, so I could clip it at some distance by myself. You’ll need to check the exact data you get from SciPy. In the 3D world you’ll almost always want to remove such infinite areas to get any meaningful rendering, or at least remove the area that contains your camera.

Points generation:

The Poisson disc is fine as some sample data or for early R&D but it’s also the most boring one :). You’ll need more ways to generate input points. I tried to imagine the input needed for your ball-like example and I came up with something like this:

  1. Create two spheres of points, with the same center but different radius.

When you create a Voronoi diagram out of it and remove infinite areas you should end up with something like a football ball.

If you created both spheres randomly you’ll get very irregular boundaries of the ‘ball’, but if you scale the points of one sphere, to use for the 2nd one you should get a regular mesh, similar to ball. You can also use similar points, but add some random offset to control the level of surface irregularity.

  1. Get your computed diagram and for each edge create few points along this edge - this will give you small areas building up the edges of bigger areas. Play with random offsets again. Try to ignore edges, that doesn't touch any infinite region to get result similar to your image.

  2. Get the points from both stages and compute the diagram once more.

Mesh generation:

Up to now it didn’t look like your target images. In fact it may be really hard to do it with production quality (for a Maya plugin) but I see some tricks that may help.

What I would try first would be to get all my edges and extrude some circle along them. You may modulate circle size to make it slightly bigger at the ends. Then do Boolean ‘OR’ between all those meshes and some Mesh Smooth at the end. This way may give you similar results but you’ll need to be careful at mesh intersections, they can get ugly and need some special treatment.

Community
  • 1
  • 1
kolenda
  • 2,741
  • 2
  • 19
  • 30