Select Faces By Element Volume
Genome provides pre-defined face channels containing the area, volume and centroid position of the mesh element the face belongs to. In addition, a dedicated ElementQuery operator can be used to access this information from external geometry.
In the following example, we will select the faces of elements based on the element's volume.
The base scene contains a Standard Particle Flow set to emit 2000 particles over 100 frames with Speed set to Reverse and 30.0 Divergence, all other parameters left at their defaults. The Particle Flow was then meshed using the Frost particle mesher using the Zhu-Bridson algorithm:
As you can see, there are some tiny droplets between the larger parts of the mesh, as well as some detached particle blobs.
- Add a Genome modifier to the Frost object and set it to "Faces" Iteration mode.
- Open the MagmaFlow editor and press Ctrl+[O] to create an Output node, set it to FaceSelection channel.
- Press [I] and [C] and [V] to create a FaceElementVolume channel
- Press [L] and [S] to create a Logic > Less operator.
- Press Ctrl+ to connect a Float InputValue to the second socket of the Less operator. Change it to 5.0, rename it to "Threshold" and check the "Exposed" option.
- Select the InputChannel again and press [/] to insert a Divide operator. Enter 1000.0 in the Default value of the second socket - this will scale down the volume so the user does not have to enter very large numbers.
RESULT: The Faces with area below threshold of 5.0 (5000.0 cubic generic units) will be selected (left image). Change the Threshold to 50.0 (right image) to select the larger drops.
Increase the value to 200.0 (left image) to select even larger clumps. Increase to 500.0 and add a DeleteMesh modifier to the stack above the Genome modifier to delete the selected faces (right image):
Setting Color Instead Of Selection (WIP)
Using the same approach, we can colorize the mesh based on, say, the Area of the Elements:
- Disable the previous Genome modifier.
- Add a new Genome modifier, set it to "CUSTOM FACE VERTEX" iteration mode.
- Open the Editor and press Ctrl+[O] to create an Output node, set to Color channel.
- Select the Output node again and press [I] and [C] to open the channels menu, then select FaceElementArea from the list.
- Press [/] to insert a Delete modifier to the flow.
- Press Ctrl+ to connect a Float InputValue. Rename it to "Max.Area" and check "Exposed". Change the value to 40000.0.
- Select the Divide operator and press [F] and [B] to insert a Blend operator.
- Press Ctrl+[W] and then SHIFT+Ctrl+[W] to swap the first and second and second and third sockets, bringing the connection to the 3rd socket.
- Press SHIFT+ to connect a Vector InputValue with a value of [1,1,1] (white).
- Press SHIFT+ to connect a Vector InputValue with a value of [0,0,1] (blue).
- Select the Divide operator again and press [F] and [C] to insert a Clamp operator. This is to make sure the Area ratio value never exceeds 1.0, but is not madatory.
RESULT: A color gradient between blue (large area) and white (tiny area) is assigned to the Vertex Color channel of the mesh.