Select Page

There are many reasons you might want to access mesh information in a MASH network, we’ll take a look at two of those reasons here.

  • In part 1 we’ll look at turning points off based on mesh normals.
  • In part 2 we’ll look at setting point Ids based on mesh vertex colours.

For the mesh normals, the process is fairly easy, we ask the MASH API to give us the Distribute node of the network, we then ask the Distribute node for the mesh you’re distributing on, once we have that mesh, we query the closest normal to the MASH point. The end goal here is to say ‘if the mesh normal is pointing more then 20 degrees away from up, turn the point off’. In the above images this has the effect of turning the trees off on steep slopes.

Check out the script. You can copy and paste this onto any Python node (make sure your MASH network has a mesh distribution, otherwise there will be no normals to sample!).

The World node has this ‘slope’ filtering built in, but this kind of technique is useful if you aren’t using that node (for whatever reason, e.g. you want to have a completely manual placement via the Placer node, or you want a more random scattering via the Distribute node).

If performance is important to you, I highly recommend investigating the MMeshIntersector class and using that instead of MFnMesh’s closest normal command as the mesh intersector is a lot faster at this task (it takes a bit more setup which would confuse the example, so I haven’t used it here).