Splitting an edge into equal-length new edges


Here’s the basic idea of how to split an edge into N equal-length new edges. Notice how I work backwards (in the sense that my split ratio decreases). That way I don’t know have to know (or care) about the new edges. I just keep splitting the same edge, whose EdgeIndex I already know.

SplitEdge0

SplitEdge1

SplitEdge2

SplitEdge3

Based on that observation, here’s a rough draft of an ICE tree that takes an edge of length N, and splits it into N equal-length edges.

SplitEdges

Saturday snippet – ShaderDef attributes


Getting shaderdef attributes.

si = Application
#sdef = si.GetShaderDef( "Softimage.BA_particle_density3.1.0" )

sdefs = si.ShaderDefinitions
print sdefs.Count # 1390

for sdef in si.ShaderDefinitions:
	print sdef
	for n,v in map( None, sdef.Attributes.Names,sdef.Attributes.Values ):
		print "   %s=%s" % (n,v)

For most shaderdefs, the only attributes are “shaderlocation” and “thumbnail”.
Softimage.BA_particle_density is one of the few that has anything more interesting. If a Softimage.BA_particle_density shader exists in the scene, you’ll get this:

# Softimage.BA_particle_density3.1.0
#    shaderlocation=3
#    thumbnail=particle.bmp
#    {C535FA4D-E44A-45EB-AEE0-9F9AAEA91745}=None
#    {20ECB4F8-A4A1-44FE-956A-0F6E98D541A8}=Color,Id,PointVelocity,Orientation,Size,PointPosition,Age,AgeLimit,StrandPosition,StrandVelocity,StrandSize,StrandOrientation,StrandColor

If you look at the BA_particle_density3 spdl, you’ll see that that last attribute corresponds to the “ICEattribute” entry for the output parameter. That ICEattribute tells Softimage to pull date from the ICE tree during rendering.

SPDL
Version = "2.0.0.0";
Reference = "{047CA80F-9EED-4507-9F83-4BB77C01DFC1}";
PropertySet "BA_particle_density3_params"
{
	Parameter "out" output
	{
		title = "BA_particle_density3 output parameter";
		guid = "{0B955B1D-CCBA-4B68-9CD3-ABE9467D665D}";
		ICEattribute = "Color,Id,PointVelocity,Orientation,Size,PointPosition,Age,AgeLimit,StrandPosition,StrandVelocity,StrandSize,StrandOrientation,StrandColor";

Assigning a per-object random value with ICE


Suppose you want to use an ICE attribute to drive some behavior in the render tree. For example, you may want to introduce some randomization to a procedural texture. Here’s one way to go about it.

First, create an ICE attribute on each object. You’ll use this object as the seed for the Random Value node (you need a different seed for each object, otherwise you’ll get the same “random” number for each object).

si = Application
i = 0
for o in si.Selection:
	a = o.ActivePrimitive.Geometry.AddICEAttribute("_seed1", 2, 1, 1  )
	a.DataArray = [ (i) ]
	i = i + 1

Now apply a simple ICE compound to each object.

Seed and random scalar value for each object

Seed and random scalar value for each object


All the compound does is feed the seed into a Random Value node, and store the random value in another ICE attribute.
PerObjectRandomValueCompound

Deleting particles by ID


Let’s say you wanted to delete certain points for some reason; maybe they were misbehaving or something. You could just stick the IDs into an array and feed that into Find in Array, like so:

DeletePointsByID

This is an answer to a question on si-community, which timed out on me when I clicked Submit. So now it’s my post for today. After struggling with Maya nParticles for an hour, I can’t think hard anymore.