Create a Rule to combine properties
Compose a Rule to manipulate two properties of your model at the same time, using a slider that combines the trunk height and radius of an existing tree model.
Read time 3 minutesLast updated 2 hours ago
This procedure builds a single slider that adjusts both the trunk height and radius of an existing tree model together, working up through the following sections.
Create a slider with a normalized range
-
From the menu, select Window > Rules.
-
In the script editor of the Rules window, compose the following statement:GrowthValue = rule("Growth", 0.5, 0.0, 1.0)
-
Click anywhere outside the Rules window.
The UI section of the Rule window displays a slider named Growth in a section named Shape. The slider allows you to change the value of a variable named between and and the default value is .
GrowthValue010.5Make the slider proportionally control the trunk height
-
Create and isolate a localvariable and interpolate its value in a suitable range according to the slider's range.
TrunkHeightGrowthValue = rule("Growth", 0.5, 0.0, 1.0)do local TrunkHeight = math.lerp(20, 80, GrowthValue)endIn this example, thefunction makes themath.lerpvariable value linearly change betweenTrunkHeightand20when you move the slider between between80and0.1 -
Select the Trunk generator of the tree.
-
In the Property Bar, select the Spine tab.
-
Under Spine > Length, right-click on the Absolute property and select Copy edit line for script.
-
Under the local variable statement in the Rule editor, paste the copied information.
-
Update theparameter of the
VALUEfunction to match the Rule's variable name (set_property_value):TrunkHeightGrowthValue = rule("Growth", 0.5, 0.0, 1.0)do local TrunkHeight = math.lerp(20, 80, GrowthValue) set_property_value("=Trunk", "Spine:Length:Absolute", TrunkHeight)end -
Click anywhere outside the Rules window.
When you adjust the slider, the trunk of the tree gets longer or shorter.
Combine the trunk radius with the trunk height
-
Create a localvariable and interpolate its value in a suitable range according to the slider's range.
TrunkRadiusGrowthValue = rule("Growth", 0.5, 0.0, 1.0)do local TrunkHeight = math.lerp(20, 80, GrowthValue) local TrunkRadius = math.lerp(0.2, 1.2, GrowthValue) set_property_value("=Trunk", "Spine:Length:Absolute", TrunkHeight)endIn this example, thefunction makes themath.lerpvariable value linearly change betweenTrunkRadiusand0.2when you move the slider between between1.2and0.1 -
Select the Trunk generator of the tree.
-
In the Property Bar, select the Skin tab.
-
Under Skin > Radius, right-click on the Absolute property and select Copy edit line for script.
-
Under the firststatement in the Rule editor, paste the copied information.
set_property_value -
Update theparameter of the new
VALUEfunction to match the Rule's variable name (set_property_value):TrunkRadiusGrowthValue = rule("Growth", 0.5, 0.0, 1.0)do local TrunkHeight = math.lerp(20, 80, GrowthValue) local TrunkRadius = math.lerp(0.2, 1.2, GrowthValue) set_property_value("=Trunk", "Spine:Length:Absolute", TrunkHeight) set_property_value("=Trunk", "Skin:Radius:Absolute", TrunkRadius)end
When you adjust the slider, the trunk height and radius values get higher or lower at the same time.