Passing arrays of values and indices to Set in Array


When I’m not sure how a node processes its input, I’ll build a little test tree to find out. For example, if I connected arrays to the Index and Value ports of Set in Array, I wasn’t sure if I would get this:

Result[ Index[i] ] = Value[ Index[i] ]
or this:
Result[ i ] = Value[ Index[i] ]
or this:
Result[ Index[i] ] = Value[ i ]

So, I used Build Array from Constant to build an array with a given size, then, for convenience, I use String to Array to build a Index array and a Value array. Then I connected the output to a Set Value, and Show Values showed me that Given these two arrays, Set in Array does this:

Result[ Index[i] ] = Value[ Index[i] ]

In practice, you’re probably more likely to use an Index array like [0,1,2,…], so you’ll effectively have this:

Result[ i ] = Value[ i ]

ICE Modeling: Building a faster duplicator compound


On the XSI mailing list, Guillaume Laforge posted some interesting information about how to build an efficient duplicator compound. He also posted a new version of Create Copies from Polygon Mesh.

Basically, if you want to lots of duplicates, then you’ll find Create Copies from Polygon Mesh to be a bit slow. That’s because it uses Merge Topo Array, which is designed to handle the merging of meshes with different topologies. To duplicate an object, it’s better to use Create Topo.

To use Create Topo, you need two arrays:

Guillaume goes through all this in his post, but here’s my take, starting with the vertex position array.

To build this array, we start by getting an array of the point positions for the original mesh, and then building a new array that contains a copy of the point positions for each duplicate. So if the original mesh has M vertices, and we want to create N duplicates, the array will contain M*N elements.

To build this vertex position array, we use the modulo trick to repeatedly select elements from the array. There are two reasons for doing it this way: we can allocate the array size just once, and we don’t use any repeat nodes.

I find it helpful to visualize this with a simple case. So here’s a screenshot for a single polygon mesh. Note the array created with the modulo operator. By feeding this into the Select in Array node, we end up duplicating the original point position array once for each duplicate.

Note also the use of Build Array from Set, to build a singleton array out of the per-point PointPosition data set.

Emitting particles from polygon clusters


Here’s an ICE tree that emits a particle from each polygon in a cluster.
In Emit from Position, I’ve set the Rate Type to Total Number of Particles, and the Rate to 1, so I get a single particle per polygon.

I exploded the Align to Emit Location compound and modified it to use the PolygonNormal to align the particles (which I’ve set to “cones”).

Hat tip: Sebastian Kowalski on the XSI mailing list

ICE modeling: Building a polygonal description


In this video, I use a simple example (a 2×2 grid) to show one approach to building up a polygonal description array.

A polygonal description array is an array of vertex indices that looks something like this:

0 3 4 1 -2 1 4 5 2 -2 3 6 7 4 -2 4 7 8 5 -2

where the “-2” is a separator between polygons.

If you’re interested, the corresponding scene is here.

http://vimeo.com/22617674

hat tip to Guillaume Laferriere for the Index Array to Select Case technique.