INTRO:
Seth pointed out this great resource about expressions and HScript. It is a powerful way to get the flexibility you will need for the village project (or any final project) in the scripting class. Here is the link:
http://www.sidefx.com/index.php?option=com_content&task=view&id=1500&Itemid=305
It contains 18 videos.
I watched and summarized the most important parts with screenshots. This will help because you can better know which tutorial to watch to help you. It's a work in progress, I may not have all 18 done yet.
VIDEO 1: Introduction to Attributes, Variables, and Expressions
Skip first 6 minutes (talks about setting key frames for values)
Any legal math expression that you can type into a calculator, you can type into the value box in Houdini
In the following examples, you can ignore the ` character. It is just used in text boxes and we rarely work in text boxes.





To learn more about modulus check out the bottom of this blog post. In short, it returns the remainder.
And you can also get into order of opperations using parentheses.
Take away: Your tools for doing calculator math in Houdini are + - * / ^ % ( )
What About Comparisons?
This is where HScript comes in handy. You can do comparisons such as less than <
greater than >
not equal to !=
greater than or equal to >=
and others using simple h script.

For example, if you put down a switch node between a circle and a sphere you can tell the switch node exaclty when to switch using an expression$F > 1
RESULT: At frames 0 and 1, the tube will be output
At framse 2 and above, the sphere will be output
The dollar sign $ just means that a built in houdini variable is being used. You can look up which other variables are available to use in the help section of Houdini.
Did you know you can have more than one condition?
You can also use the "or" operator and the "and" operator.
OR = ||
AND = &&
So what if I only want an input inbetween frame 6 and 44?
Then I can use the && operator to select an input when the frame number is greater than 6 AND less than 44.
More relevant example
We probably won't be using frame number in our village building assignment, however, the same principle applies. What if you have two models of roads and you want to switch between them if the user increases the road width above a certain value?
You could do something like this:
If the road width is greater than 66, switch geometry input
Translated to computer talk:
ch(../roadWidth) > 66
End of Video 1






No comments:
Post a Comment