Caffeine Abuse - The Blog

Painting weights in ICE

While the weights in the weight map will be controlled from within the ICE Tree, you have to create the actual weight map manually. Select the Grid object and from the Get > Property menu choose Weight Map. Select the Grid object and press [Alt]+[9] to open an ICE Tree and from the Create menu choose Simulated ICE Tree. Press [8] to open an Explorer and drag and drop the Sphere object to your ICE Tree. Continue by getting a Pass Trough node, a Get Point Position node and a Get Closest Location node. The Get Point Position node returns the position of each of the points of the grid which is then used by the Get Closest Location node to determine whether the Sphere touches any of the vertices of the grid object (or is within a specified distance). If the Sphere is within this value the corresponding points’ weight should be set 1. If it’s not, the weight should stay unaffected (the default value is zero). Open its PPG. Check the Enable Cutoff Distance checkbox and set the Cutoff Distance to 0.1 and close the PPG.

Connect the Get Sphere node to the In input of the Pass Trough node, and the Pass Trough node to the Geometry input of the Get Closest Location node. The Pass trough node is purely for assisting the creation of compound (see Quick Tip). Connect the Get Point Position to the Position input Get Closest Location node.

Get a Set Data node and double click on it to open its PPG. The Set Data node can be used to set any predefined value or, as in this case, a custom value. In the Reference text box enter self.AddWeight. This will create a custom property named AddWeight. While you can set the value directly from within the PPG, using a separate node for this will make it easier to ‘read’ the ICE tree just by looking at it. So, get a Scalar node set its Value to 1 and connect it to the self.AddWeight input of the Set Data node. Get a If node and connect the Found output of the Get Closest Location node to the Condition input of the of the If node. Then connect the Set Data node to the If True input of the If node. Get a Execute node and connect it to the Port1 input of the ICETree node. Then connect the If node to the Port1 of the Execute node.

Get a Get Data node and open its PPG. Enter self.AddWeight in the Reference text box. Get a Set Data node, open its PPG and click the explore button. In the Explorer, expand the Grid > Polygon Mesh > Clusters > WeightMapCls > Weight_Map and select the Weights node. In the Reference text box, replace the word Grid with self and close the PPG. Connect the get self.AddWeight node to the self.clsWeightMapCls.Weight_Map.weights input of the Set Data node. Conclude the tree by connection the Set Data node to the New (port1) input of the Execute node.

The project files used in this tutorial can be found at:
A weight map essentially enables you to store a weight value for each point of an object (or part of your object if you’re using clusters)…which can be used to control anything from particle emission, shape animation and deformers to defining custom material properties of on object.

Quick tip
In the ICE Tree, select all but the Get Sphere and ICETree node, and from the Compounds menu choose Create Compound. Your ICE compound can now easily be saved to your library for later use.