mardi 29 mars 2016

Randomly generated 3D points distributed on a density map

This topic may look like this one but I'd like some more details for this specific case.

Here is the thing.
I generate x 3D points on a surface whith the following method:

  • With:
    • a given 3D surface only composed by triangles
    • a given number of samples
  • Pick a random triangle on the surface
  • Generate a random point belonging to this triangle (with this formula)
  • Repeat for each sample

First, I'd like to improve the "pick a random triangle" part by taking account of the area of each triangle of the mesh to have a more uniform distribution (like suggested here).

Now I want to paint a grayscale map on my surface which will work as a density map: 100% white areas will receive the maximum number of points, 100% black areas won't receive any point, and intermediates grayscales will receive a percentage of points corresponding to the percentage of white at the given position.

The thing is, even with the right formulas and mathematical concept, I have some hard time "translating" math into code... So I was wondering how would you do it, step by step, like in pseudo-code or something. I usually work with Maya and python but it is more like a general math-to-code-question.

Thanks by advance!




Aucun commentaire:

Enregistrer un commentaire