Monday, April 16, 2012

ICE and Data Providers

When I decided to create a curve extrusion tool (a.k.a. Power Extrude) to learn ICE modeling, I already know that it could not support subcurves, for the simple fact that ICE still does not provide enough information about curvelists.

For example, there is no way for you to know how many subcurves you have, the length of each subcurve or whether a curve is open or closed. You can always make assumptions, like subtract the first and last point positions, compare to a threshold, and define a curve as closed, but you'll never be sure that is a valid information.

In the case of Power Extrude, I really wanted to support the multi-subcurve feature, it would be useful as there's no way to do it with Soft's default extrusion. I like to judge my compounds by their advantage over factory tools, and not just because they are ICE based. (you are not supposed to reinvent the wheel, but rather polish it to drive faster!)

So to overcome this limitation I came up with something called "Data Provider". This Data Provider acted as a bridge between ICE and the Softimage SDK, filling my compound with all the extra information I missed from default ice attributes...the hacky way.  =)

Of course "good practice" would be to create a c++ custom node (better performance), but I didn't had the proper time to learn c++ and don't wanted to stop experimenting because of that, so I had to stick to the good ol'javascript.

The concept is very simple: on each curvelist used by the compound (path or profile) there is a Scripted Operator running on the secondary shape modeling stack. It reads all the needed information through scripting and feeds a custom parameter set.


This parameter set has string arrays which are manipulated in the icetree to produce typed information for general use.

"Array index" expects the subcurve from where you want to extract information from. 
"Error String" outputs a descriptive message if the provider is missing or an empty string in case it is found. 


At first I was not sure about the performance, but it proved to be quite efficient for the kind of information I needed. The parameter set is placed higher in the stack and updated at every curve change, so you can tweak, reshape, add/delete knots, open/close or do whatever you want to the curve, without fearing the data provider would pass wrong attributes to the icetree.

Conclusion: everyday I'm finding some new uses for this thing (extra curve information, number of passes, active pass, active viewport, number of children for a specific object, etc). It always come in handy from time to time, until the day ICE will take over and hopefully access every bit of information we may want inside Softimage world.


No comments:

Post a Comment