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:
- An array of vertex positions.
- An array of polygon descriptions.
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.
Thanks for your explanation, very useful!
I just wanted to recreate this
with this faster Create Copies from Polygon Mesh v. 2.0 compound, but the Transform per Copy compound does not work, because the Self.CopyTopology_Transforms is not initialized. Any ideas how to solve it, to make it work?
Guillaume posted an updated compound to fix that problem.