User Tools

Site Tools


Environment Backdrop Dialog

Summary

Below is an example demonstrating how to cause the Environment pane to be displayed. If the pane is docked, it becomes the active pane of the group. If the pane is not docked, the pane is shown in a non-modal dialog.

API Areas of Interest

Example

Environment_Pane_as_Backdrop_Dialog.dsa
// DAZ Studio 4.7.0.12
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
( function(){
 
	// Get the pane manager
	var oPaneMgr = MainWindow.getPaneMgr();
	// If we don't have a pane manager
	if( !oPaneMgr ){
		// We're done...
		return;
	}
 
	// Get the environment pane
	var oPane = oPaneMgr.findPane( "DzEnvironmentPane" );
	// If the pane was not found
	if( !oPane ){
		// We're done...
		return;
	}
 
	// Get the group the pane is currently in
	var oPaneGrp = oPane.getPaneGroup();
 
	// If the pane is not in a group; has not been displayed this session
	if( !oPaneGrp ){
		// Put the pane in its own undocked group
		oPaneMgr.tearOffPane( oPane );
 
		// Update the group the pane is currently in
		oPaneGrp = oPane.getPaneGroup();
	// Otherwise
	} else {
		// Make the pane [group] visible
		oPaneMgr.showPane( oPane );
	}
 
	// If the group is docked
	if( oPaneGrp.isDocked() ){
		// We're done...
		return;
	}
 
	// Put the pane in its own non-modal dialog
	oPane.makeUndockable( new Size( 250, 240 ) );
	// Get the group the pane is currently in
	oPaneGrp = oPane.getPaneGroup();
	// Hide the tab bar for the group
	oPaneGrp.hideTabBar( true );
 
	// Get the backdrop for the scene
	var oBackdrop = Scene.getBackdrop();
 
	// If the backdrop is visible
	if( oBackdrop.visible ){
		// We're done...
		return;
	}
 
	// Define a default background color
	var clrBackground = new Color( 255, 255, 255 );
 
	// Get the viewport manager
	var oViewMgr = MainWindow.getViewportMgr();
	// Get the active viewport
	var oView = oViewMgr.getActiveViewport();
	// Get the 3D viewport
	var o3DView = oView.get3DViewport();
	// If we have a 3D viewport and the backdrop
	// does not have a texture
	if( o3DView && !oBackdrop.getTexture() ){
		// Get the background color of the 3D viewport
		clrBackground = o3DView.background;
	}
 
	// Set the backdrop background color
	oBackdrop.backgroundColor = clrBackground;
 
	// Make the backdrop visible
	oBackdrop.visible = true;
 
// Finalize the function and invoke
} )();