User Tools

Site Tools

Scripted Renderer Settings


Below is an example demonstrating how you can set the active renderer to DzScriptedRenderer and also set the definition file, via script. This file can be placed in a mapped content directory and used as a “Preset” that switches to a specific [default] configuration of the “Scripted 3Delight” renderer.

API Areas of Interest


// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
	// String : A function for retrieving a translation if one exists
	function text( sText )
		// If the version of the application supports qsTr()
		if( typeof( qsTr ) != "undefined" ){
			// Return the translated (if any) text
			return qsTr( sText );
		// Return the original text
		return sText;
	// Define the base path for scripted render definition files
	var sDefinitionBasePath = String("%1/Scripted Renderer/").arg( App.getResourcesPath() );
	// Define the relative path for this definition file;
	// leave off the extension so we can dynamically load it
	// regardless of whether it is a dsa for development/debugging
	// or a dsb/dse for distribution
	var sRelDefinitionPath = "Outline/Outline";
	// Define the path of the scripted render definition file
	var sDefinitionPath = String("%1%2").arg( sDefinitionBasePath ).arg( sRelDefinitionPath );
	// Copy the path in case we need to alert
	var sMessage = sDefinitionPath;
	// Create a script object; for access to its functions
	var oScript = new DzScript();
	// Re-define the path of the definition file; with its dynamic extension
	sDefinitionPath = oScript.getScriptFile( sDefinitionPath );
	// If the file does not exist
	if( sDefinitionPath.isEmpty() ){
		// Inform the user
		MessageBox.warning( text( "%1.ds(a|b|e) could not be found." ).arg( sMessage ),
			text( "File Not Found" ), text( "&OK" ), "" );
		// We are done...
	// Get the render manager
	var oRenderMgr = App.getRenderMgr();
	// Find the scripted renderer
	var oRenderer = oRenderMgr.findRenderer( "DzScriptedRenderer" );
	// If the renderer was not found
	if( !oRenderer ){
		// Inform the user
		MessageBox.warning( text( "The \"Scripted 3Delight\" renderer could not be found." ),
			text( "Resource Error" ), text( "&OK" ), "" );
		// We are done...
	// Set the active renderer
	oRenderMgr.setActiveRenderer( oRenderer );
	// Re-define the relative path for the definition file
	sRelDefinitionPath = sDefinitionPath.slice( sDefinitionBasePath.length );
	// Set the definition file path; relative
	oRenderer.setDefinitionFile( sRelDefinitionPath );
	// Cause any updates that need to happen
// Finalize the function and invoke