Finding shader nodes with no connections


Here’s a JScript snippet that finds render tree nodes that are not connected to anything in the render tree.

LogMessage( isConnected( Selection(0) ) );

function isConnected( o )
{
	var oDR = XSIUtils.DataRepository ;

	var strOpInfo = oDR.GetConnectionStackInfo( o )
//	LogMessage( strOpInfo );
	var oTopNode = ParseXML( strOpInfo ) ;

	var oConnections = oTopNode.childNodes ;
	if ( oConnections.length == 0 )
	{
		return false;
	}
	return true;
}

function ParseXML( strXML )
{
	var oXMLParser = new ActiveXObject("Microsoft.XMLDOM") 
	oXMLParser.async = false	
	oXMLParser.loadXML( strXML ) ;

	if (oXMLParser.parseError.errorCode != 0) 
	{
		logmessage( "Invalid XML " + oXMLParser.parseError.reason , siError ) ;	
		return null ;
	}

	// the xsi_file node
	// If this is NULL we must have failed to load the XML
	var oTopNode = oXMLParser.documentElement ;

	return oTopNode ;
}

Most of this JScript came from the SDK Explorer code in $XSI_HOME\Addons\sdkui\Application\Plugins\SDKExplorer.js, because I noticed that disconnected shaders would have an empty connection stack, and I didn’t want to go through all the parameters individually looking for connections.
SDK_Explorer_Connection_stack_is_empty

Here’s a Python version that does a little more: it follows the output connections to check whether or not the shader is ultimately connected the material.

# Python Code
import xml.etree.ElementTree as etree

def is_connected( o ):
	if not o.IsClassOf( 52 ):
		print "Input is not a shader"
		return False
		
	sXML = XSIUtils.DataRepository.GetConnectionStackInfo( o )
	root = etree.fromstring( sXML )
	for connection in root:
		if connection.find('type').text == 'out':
			x = Application.Dictionary.GetObject( connection.find('object').text )
			return True if x.IsClassOf( 64 ) else is_connected( x )
				
	return False

print is_connected( Application.Selection(0) )

ICE: Building an array from an fcurve


Suppose you have an animated scalar value, and you want to store its values as you play through a simulation. And suppose you also want to keep a running total of all the values up to the current frame.

My first try used two arrays: one to store the values at each step through the simulation, and one to hold the running total.
FcurveArray1

Calculating the array sum at every step seems wasteful. So, here’s my second try at keeping a running total of the values from the fcurve. I use just one attribute and one array. The attribute was necessary because if I plugged Pop from Array directly into Add, I got nothing.
FcurveArray2

Softimage 2014 cachedat files


Here’s something I noticed when I started up Softimage 2014 SP2 for the very first time. It spent about 26 seconds writing some cachedat and cachehdr files in my User folder:
Startup_file_summary
During subsequent startups, Softimage just reads in the cachedat, which takes a lot less time (eg < 0.005 seconds).

I looked back at my previous versions of Softimage, and it seems these cache files were new in 2014. There's actually two cachedat files, each with an associated cachehdr header. You'll find them in your %XSI_USERHOME%\Cache folder:

C:\Users\xsisupport\Autodesk\Softimage_2014_SP2\Cache\{870AB238-90C2-4336-8D46-B2CDD31C8A34}.cachedat
C:\Users\xsisupport\Autodesk\Softimage_2014_SP2\Cache\{870AB238-90C2-4336-8D46-B2CDD31C8A34}.cachehdr
C:\Users\xsisupport\Autodesk\Softimage_2014_SP2\Cache\{AD8CCDD2-C275-46E3-9881-265DB5BC84BB}.cachedat
C:\Users\xsisupport\Autodesk\Softimage_2014_SP2\Cache\{AD8CCDD2-C275-46E3-9881-265DB5BC84BB}.cachehdr

One cache is read at startup. The other is updated when you first drag an ICE node into an ICE tree (and then if you start a new XSI.exe session and drag the same node into an ICE tree, Softimage will read from the cache). Running strings on these cache files showed lots of ICE node/compound names, so they seem to be strictly for some sort of ICE-node caching (eg ports, layouts, logic, …).

Friday Flashback #127


Falling Bodies, the Softimage|3D plug-in for creating your own fall stunts.
boxpicture2
From the Animats web site:

Animats introduced ragdoll physics technology in 1997. The Animats Falling Bodies> product was for years the most advanced ragdoll dynamics system on the market. Our technology for high-quality ragdolls is patented. This broad patent covers most spring/damper character simulation systems. If it falls, it has joints, it looks right, and it works right, it’s usually covered by our patent. This technology has been licensed to a major distributor of game development middleware.

This is the original “ragdoll falling down stairs” animation, shown at the Softimage user group meeting in 1997. This is the first ragdoll demo ever. U.S. Patent #6,067,096.

–quote from the youtube version of this video (which wouldn’t play properly in Chrome, hence the vimeo version above)

Workarounds for caching ICE attributes [and sidestepping ICE optimizations]


Because of how ICE is optimized, it won’t bother setting data if you never use that data (see Beware of ICE Optimizations here). For example, suppose I have a point cloud where I set a per-point scalar value, but I never use that scalar data (because I just want to cache that value and use it later).

ICE_Opt_1

That scalar attribute is never used, so it is optimized away (it makes sense: you’re not using it, so why keep it?). You won’t see that attribute in the Cache Manager, and the Cache on File node won’t write it out (even if you add that attribute to the list).

One way to force ICE to evaluate the attribute so you can cache it is to create an Attribute Display property for the attribute, but disable Show Values.
ICE_Opt_AttributeDisplay

Another way is to insert a Log Values node, and disable logging.
ICE_Opt_Log

Yet another way is to use Show Values. Enable Show Values for Tagged Components Only to hide the values (if you’re going to tag components, you could set the Display % to 1).
ICE_Opt_ShowValues

And last but not least, if you have emTools from Mootzoid, you can use the Force Value Evaluation node, which uses a Show Values on a value that is never set.
emToolsForceValueEvaluation

hat tips to Stefano, Mathieu, and Vincent on the SItoA list