Using Generate Sample Set to avoid the Repeat node

Hat tip to Oleg who posted this tip on the mailing list some time ago.

The basic ideas is that instead of looping over an array with a Repeat with Counter, you use Generate Sample Set to get a data set, and you do everything in a per-generated element context.


As an example, let’s revisit the problem of taking one array and creating a new array where each element is the sum of the elements before it.


The old way, with a Repeat with Counter node, looks like this:

Using Generate Sample Set, you can work with a data set and use that to access the array elements:

Generate Sample Set is set up to give an exact number of samples:

Screenshots of the week

Particle clumping
by Andy Moorer

MatCap (litsphere) shading in Softimage 2013
by Andy Moorer

Matcap render tree
by Gustavo E Boehs

MatCap Mirror ball/Map ball
by Gustavo E Boehs

Paint polygons by weightmap delete holes
by Tekano

by Maximus

by msktkhs

How to convert weightmap to geometry in softimage ICE tutorial

Old school Quantum Teleportation

Saturday Snippet: Getting data from a DataArray2D ICE attribute

I wanted to do this JScript, but I had to do it in Python first, to establish that it was actually possible (with JScript, you’ve got to mess around with VBarrays and such).

# Using one of the CrowdFX sample scenes:
Application.SelectObj("Pedestrian_Mesh.Actor_Copies", None, None);
o = Application.Selection(0)

a = o.ActivePrimitive.Geometry.GetICEAttributeFromName("Materials")
print len(a.DataArray2D)
print len(a.DataArray2D[0] )
print a.DataArray2D[0][0]
for s in a.DataArray2D[0][0]:
    print s

# 1
# 1
# (u'', u'Sources.Materials.PedestrianLib.Shoes', u'Sources.Materials.PedestrianLib.Hair', u'Sources.Materials.PedestrianLib.Legs', u'Sources.Materials.PedestrianLib.Skin', u'Sources.Materials.PedestrianLib.Shirt')
# Sources.Materials.PedestrianLib.Shoes
# Sources.Materials.PedestrianLib.Hair
# Sources.Materials.PedestrianLib.Legs
# Sources.Materials.PedestrianLib.Skin
# Sources.Materials.PedestrianLib.Shirt

After I had it working in Python, I was able to figure it out in JScript:

// Using one of the CrowdFX sample scenes:
SelectObj("Pedestrian_Mesh.Actor_Copies", null, null);
o = Selection(0);

a = o.ActivePrimitive.Geometry.GetICEAttributeFromName("Materials");

x = new VBArray( a.DataArray2D ).toArray();
y = new VBArray( x[0] ).toArray();
for ( var i = 0; i < y.length; i++ )
    LogMessage( y[i] );

Softimage announce and release dates

It’s getting to be that time of year when people start asking about the next version…

You can probably get a pretty good idea of when to expect Softimage 2014 by looking backwards. So, here’s the dates that previous versions were announced and released (data gathered via google).

Release Announced Released
2013 27 March 2012 12 April 2012
2012 01 March 2011 07 April 2011
2011 15 March 2010 06 April 2010
2010 03 August 2009 14 Sept 2009
7.5 23 Feb 2008 23 Feb 2008

Hexagon tiling with ICE

Here’s a relatively simple ICE tree that arranges hexagons on the XZ plane. The “difficult” part was creating the arrays of position coordinates. For that I used the standard modulo technique. It’s funny, it all makes perfect sense when you’re plugging stuff together, but afterwards it’s hard to make heads or tail of what you did 🙂

To understand what’s going on here, it helps to look at the final arrays that are built:

The math for arranging the hexagon tiles is pretty simple. I started with a simple test point cloud to make sure I understood what I needed to do. After that, it was just a question of setting up the arrays.

If you want to take a look at the ICE trees, here’s some compounds. Note that this isn’t a finished piece of work. It’s more of a draft version. For example, my hexagon has a side length of 5 and that’s hardcoded into the ICE tree right now.

ICE: Building a regular hexagon

Let’s build a regular hexagon!

In this example, I take the vector (5,0,0) and rotate it by 60 degrees, then 120, then 180, and so on, until I have the 6 points of the hexagon. In ICE, that equates to getting an array of rotations, stuffing that into Rotate Vector, and getting an array of positions back.

Notice how the length of each side is the same (5), as is the distance of each point from the local origin.

Before I jumped into building the polygon, I first did a quick test with a point cloud, to make sure I understood how to add points in the right places. In general, I think it’s good practice to do some kind of “proof of concept” before you really dive into the details.

Screenshots of the week

LKLightning 2.0 Tutorial 01 – Swirling7

Display debug per-object attribute on distant point cloud
by Fabricio Chamon

Moving cached geometry
by Alok Gandhi

by NNois

Turbulize Null position
by Helli

Splitting edges
by iamVFX, julian johnson

Finding he indices of negative values in an array
by iamVFX

Saturday Snippet: Getting the object under the mouse in a context menu callback

For most context menus, the Target attribute contains both the selected objects (if any) and the object under the mouse.

def MyCustomMenu_Init( in_ctxt ):
    oMenu = in_ctxt.Source
    oMenu.Filter = "camera"
    oMenu.AddCallbackitem("Custom Camera Tool","MyCameraTool")
    return true

def MyCameraTool(in_ctxt):
    obj = in_ctxt.GetAttibute("Target")

I’m pretty sure I’m the one who dug up that info and put it in the docs (on the Menu Item Callback page). I did not, however, write this bit, which to my ear does not sound good at all:

If your menu is attached to a contextual menu, the currently selected objects are passed in to your callback. The target object under the cursor is also passed in as part of the selected objects. However if no objects are selected, then only the target is passed in. The objects can be retrieved through the Context.GetAttribute method with “Target” specified as the value for the AttributeName parameter. The selected/target objects are not passed in to the callback of a custom menu item attached to a regular menu.

I prefer something more like this:

For context menus, the callback gets the currently selected objects and the object under the mouse. You can get these target objects from the Target attribute with Context.GetAttribute.