User Tools

Site Tools


Scripted Renderer Definition File List

Summary

The menu for the Render Script (Definition File) property on the Scripted 3Delight renderer is constructed from the folder structure that resides within the “./resources/Scripted Renderer” directory of the application home path. The items in the menu, be they represented as a click-able action or as a submenu, are each created from the names of the folders.

  • Actions are created for each of the “leaf” (deepest) folders in a given branch of the hierarchy. When one of these actions is clicked, the path of the script in the folder named identically to that folder is passed to DzScriptedRender::setDefinitionFile().
  • Submenus are created for all other folders in a given branch of the hierarchy. Due to the fact that nesting is used to construct the menu/submenu structure, any script that is not in a “leaf” folder is not accessible from the property's menu.

Below is an example demonstrating how you can obtain a list of the definition files that are accessible in the Render Settings pane from the menu(s) of the Render Script property when the Render Engine is set to Scripted 3Delight.

API Areas of Interest

Example

Scripted_Renderer_Definition_File_List.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	/*********************************************************************/
	// Array<String> : A function for recursively collecting the paths of
	// definition files that can be accessed from the Render Scripts property
	// of the Scripted 3Delight renderer
	function scriptedRendererScriptRecurse( sPath )
	{
		// Create a directory object for the 'current' path
		var oDir = new DzDir( sPath );
		// Get a list of names for directories in 'this' directory
		var aDirNames = oDir.entryList( "*",
			DzDir.Dirs | DzDir.NoSymLinks | DzDir.NoDotAndDotDot, DzDir.Name );
		// Get the number of names found
		var nDirs = aDirNames.length;
 
		// If there are no subdirectories
		if( nDirs == 0 ){
			// Create a script object
			var oScript = new DzScript();
			// Construct the base path of the script we want
			var sBasePath = String("%1/%2")
				.arg( oDir.path() ).arg( oDir.dirName() );
			// Get the path of our definition script. Doing it this way,
			// we can find an ascii file or a binary [encrypted] file
			// without having to manually handle the file extensions.
			var sScript = oScript.getScriptFile( sBasePath );
 
			// If a script was not found
			if( sScript == sBasePath ){
				// We are done...
				return []
			}
 
			// Return the path of a script that can be accessed
			return [ sScript ];
		}
 
		// Initialize an array for collecting as we recurse
		var aDefinitionScripts = [];
 
		// Declare working variables
		var sDirName;
		var sSubPath;
 
		// Iterate over the directory names
		for( var i = 0; i < nDirs; i += 1 ){
			// Get the 'current' name
			sDirName = aDirNames[ i ];
			// Construct the path of the subdirectory
			sSubPath = String("%1/%2").arg( oDir.path() ).arg( sDirName );
 
			// Recurse and append any additional scripts we find
			aDefinitionScripts = aDefinitionScripts.concat(
				scriptedRendererScriptRecurse( sSubPath ) );
		}
 
		// Return the collected scripts
		return aDefinitionScripts;
	};
 
	/*********************************************************************/
	// Array<String> : A function for collecting the paths of definition files
	// that can be accessed from the Render Scripts property of the Scripted
	// 3Delight renderer
	function scriptedRendererDefinitionScripts()
	{
		// Construct the base path for definition files
		var sBasePath = String("%1/Scripted Renderer").arg( App.getResourcesPath() );
		// Recurse the path and return the results
		return scriptedRendererScriptRecurse( sBasePath );
	};
 
	/*********************************************************************/
	// Provide feedback to the console/log
	print( scriptedRendererDefinitionScripts().join("\n") );
 
// Finalize the function and invoke
})();