Warning : This is not really a step by step tutorial on how to build this compound but rather an attempt to show how you can translate an idea in “ICE language” .
In this post I will explain some parts of the first compound used to get some Polygon Islands Transformation using ICE.
The target audience is more ICE beginners than experienced one but it could still be interesting for hardcore user (at least, I hope…).
So lets take a look at the first compound named “Get Lowest Point Index By Islands” !
First, I must confess that this compound is not mine. I just customize a compound posted by Graham Fuller on the Softimage mailing list .
This compound find the lowest point index for each polygon islands in a polymesh.
It gives the opportunity to explain smart ICE concepts like, “Context”, “Initializing Data”, “Element Index” and “Location”.
Given for example three points, it is easy to find witch one got the smaller index. But in ICE it is not so simple. You have to think from where you are looking for.
Can you see all points and their indexes at one glance ? Or are you on one single point at a time ? In the first case, you would be in “Per Object Context”. In the second case, you would be in “Per Point Context” and so you could only see the current processed point (in fact several points can be processed at the same time in ICE but we don’t need to know it ). The first case won’t help us to much as by default ICE doesn’t give us and array of points data. We could build it but it won’t be very memory effective as we would need to duplicate existing per point data into a per object data (we will see later than sometime it can be a good option).
But the second case give us all we need. From point A, we can use the “PointNeighbors” attribute. It will return all the points connected to our point A by an edge. So we could compare point A index to point neighbors index
and store the lowest index. If we repeat this operation a “certain amount of time” we should get the lowest index in each polygon islands ! There are two things we need to solve. The first one is how can we know the point index, and the second one is how many time should we repeat this operation ?
Getting a point index in ICE :
It can be disturbing (specialy for Houdini user) to not be able to directly Get a Point Index attribute. ICE doesn’t expose Point Index as an “Intrinsic ICE Attributes” (as they are called in the user guide).
So we need to create a “Custom ICE Attibute” to store this index. You can use the built in compound name “Get Point ID” to set this custom attribute.
If you take a look at how “Get Point ID” works, you will better understand the context concept. This compound get the current object PointPosition attribute. This attribute is per point. So every node after the Get PointPosition will be in per point context.
Then, if you use the “Get Element Index” node, it will return the indices of your points. You can play with this concept be getting attributes from other contexts. For example, if you do something like :
So now that we exactly know how to store this point index attribute, we can create our “__LowestPointInIsland” attribute. The initial value of this attibute will be the point index. Notice that as I put two underscore characters, this attribute will be hidden from the explorer (as there is no reason for the user to get it).
In next post, we will see how we can compare the current point index with its neighbors and how to repeat this comparison several times in order to get the very lowest point index by island.