Interface: NitrousGraphicsManager
 
 
 

Interfaces > Core Interfaces > NitrousGraphicsManager

 

   

Core Interfaces - Quick Navigation

NEW in 3ds Max 2012: This Core Interface exposes the Nitrous Graphics Manager to MAXScript.

   

Interface: NitrousGraphicsManager

Methods:

<bool>NitrousGraphicsManager.IsEnabled() 

Returns true if the Nitrous Graphics system is enabled, false otherwise.

   

<bool>NitrousGraphicsManager.BeginPerformanceProfiling()

Starts collecting performance profiling data. For internal use only.

   

<bool>NitrousGraphicsManager.EndPerformanceProfiling()

Ends collecting performance profiling data. For internal use only.

   

<bool>NitrousGraphicsManager.DumpMemoryInfo()

Writes the current Nitrous Graphics system memory usage to a default file in the root of the 3ds Max installation.

   

<bool>NitrousGraphicsManager.DumpMemoryInfoToFile <string>maxFileName <string>logFileName

Writes the current Nitrous Graphics system memory usage to the log file specified by the second argument. The first argument is the name of the 3ds Max scene.

   

<bool>NitrousGraphicsManager.CreateDummyObjects <string>className <integer>numberOfObjects

Creates a number of dummy objects in memory using the class name provided as first argument and the count provided as second argument.

   

<IObject>NitrousGraphicsManager.GetActiveViewportSetting()

Returns a <IObject:ViewportViewSettingImpl> object which exposes the settings of the active viewport. See below for details.

   

<IObject>NitrousGraphicsManager.GetViewportSetting <integer>index

Returns a <IObject:ViewportViewSettingImpl> object which exposes the settings of the specified indexed viewport. See below for details.

   

Viewport Settings IObject Interfaces:

Interface: ViewportViewSettingImpl

This interface exposes the viewport settings as seen in the "Visual Style & Appearance" tab of the "Viewport Configuration" dialog. In addition, it provides scripted access to the parameters of the Non-Photorealistic Rendering styles which are not exposed to the User Interface of 3ds Max 2012.

Properties:

Visual Style group of controls

<ViewportViewSettingImpl>.VisualStyleMode : enum : Read|Write

VisualStyleMode enums: { #Realistic | #Shaded | #Facets | #ConsistentColors | #HiddenLine | #Wireframe | #BoundingBox | #Ink | #ColorInk | #Acrylic | #Tech | #Graphite | #ColorPencil | #Pastel }

Get/set the Viewport's Visual Style, including realistic, shaded and non-photorealistic modes. The property can be set as enum name or integer value. When getting, it will return the enum name.

Possible values are:

Numeric Value Enum Name  
0 #Realistic  
1 #Shaded  
2 #Facets  
3 #ConsistentColors  
4 #HiddenLine  
5 #Wireframe  
6 #BoundingBox  
7 #Ink  
8 #ColorInk  
9 #Acrylic  
10 #Tech  
11 #Graphite  
12 #ColorPencil  
13 #Pastel  

   

<ViewportViewSettingImpl>.ShowEdgedFacesEnabled : bool : Read|Write

Get/set the state of the "Edged Faces" viewport option.

When set to false (default), no edged faces will be displayed.

When set to true, a wireframe representation of the geometry faces will be overlayed on top of shaded faces.

   

<ViewportViewSettingImpl>.UseTextureEnabled : bool : Read|Write

Get/set the state of the "Textures" viewport option.

When set to true (default), texture maps will be displayed in the viewports if enabled at material or map level.

When set to false, texture maps will never be shown regardless of the Show Map In Viewport settings.

   

<ViewportViewSettingImpl>.TransparencyEnabled : bool : Read|Write

Get/set the state of the "Transparency" viewport option.

When set to true (default), transparency will be displayed in the viewports.

When set to false, transparency will be ignored and all objects will be displayed using solid shading.

   

<ViewportViewSettingImpl>.UseEnvironmentBackgroundColorEnabled : bool : Read|Write

Get/set the state of the "Use Environment Background Color" viewport option.

When set to false (default), the viewport background color will be taken from the corresponding value in the Customize User Interface > Color tab dialog.

When set to true, the viewport background color will be taken from the Environment Background color found in the "Environment and Effects" dialog > "Environment" tab > "Common Parameters" rollout > "Background" group of controls.

   

Selection group of controls

<ViewportViewSettingImpl>.ShowSelectionBracketsEnabled : bool : Read|Write

Get/set the state of the "Selection Brackets" option.

When set to true (default), selected objects will show selection brackets in shaded mode to denote their selected state.

When set to false, selected objects will not show selection brackets - you could enable the .SelectedEdgeFacesEnabled mode to visualize the selected state.

   

<ViewportViewSettingImpl>.SelectedEdgedFacesEnabled : bool : Read|Write

Get/set the state of the "Display Selected With Edged Faces" option.

When set to true, selected objects will be displayed with edged faces if the scene is set to shaded mode.

When set to false (default), all objects will be displayed in the current style.

   

<ViewportViewSettingImpl>.ShadeSelectedFacesEnabled : bool : Read|Write

Get/set the state of the "Shade Selected Faces" option.

When set to true (default), selected faces in sub-object level will be shaded in a solid color.

When set to false, selected faces will be highlighted using colored edges.

   

<ViewportViewSettingImpl>.ShadeSelectedObjectsEnabled : bool : Read|Write

Get/set the state of the "Shade Selected Objects" option.

When set to true, selected objects will be displayed in shaded mode even if the scene is set to wireframe mode.

When set to false (default), all objects will be displayed in the current style.

   

General options

<ViewportViewSettingImpl>.DisableViewport : bool : Read|Write

Get/set the state of the "Disable" option.

When set to false (default), the viewport will be enabled and will redraw as needed.

When set to true, the viewport will be disabled and will only redraw when manually enforced.

   

<ViewportViewSettingImpl>.ViewportClippingEnabled : bool : Read|Write

Get/set the state of the "Viewport Clipping" option.

   

Lighting group of controls

<ViewportViewSettingImpl>.LightOption : enum : Read|Write

LightOption enums: { #DefaultLight | #SceneLight }

Get/set the state of the "Lighting" > "Illuminate With..." radio buttons.

Possible values are:

#DefaultLight - illuminates the scene with one or two default lights according to the .DefaultLightMode property.

#SceneLight - illuminates using the scene lights, unless there are no scene lights in which case the illumination will fall back to the default lighting.

   

<ViewportViewSettingImpl>.DefaultLightMode : enum : Read|Write 

DefaultLightMode enums: { #OneLight | #TwoLights }

Get/set the state of the "Default Lights" radio buttons.

Possible values are:

#OneLight - illuminates the scene with one "headlight" placed behind the camera.

#TwoLights - illuminates the scene with two fixed lights.

   

<ViewportViewSettingImpl>.ShowHighlightEnabled : bool : Read|Write

Get/set the state of the "Highlights" option.

When set to true (default), specular highlights will be calculated in the viewports.

When set to false, no highlights will be calculated.

   

<ViewportViewSettingImpl>.AutoDisplaySelectedLightEnabled : bool : Read|Write

   

Shadows group of controls

<ViewportViewSettingImpl>.AmbientOcclusionEnabled : bool : Read|Write

Get/set the state of the "Ambient Occlusion" option.

When set to false (default), no ambient occlusion will be calculated.

When set to true, a screen-space ambient occlusion effect will be calculated using the settings described below:

   

<ViewportViewSettingImpl>.AmbientOcclusionRadius : float : Read|Write

Get/set the "Ambient Occlusion" > "Radius" value.

   

<ViewportViewSettingImpl>.AmbientOcclusionIntensity : float : Read|Write

Get/set the "Ambient Occlusion" > "Intensity/Fade" value.

   

   

<ViewportViewSettingImpl>.ShadowsEnabled : bool : Read|Write

Get/set the state of the "Shadows" option.

When set to false (default), no shadows will be displayed in the viewports.

When set to true, lights with shadow casting enabled will also show shadows in the viewport using the quality settings described below:

   

<ViewportViewSettingImpl>.ShadowMode : enum : Read|Write 

ShadowMode enums: { #HardShadow | #SoftShadow | #LightSettingShadow }

Get/set the Shadows Style - Hard Shadows, Soft Shadows or the Shadow type defined by the light source itself.

   

<ViewportViewSettingImpl>.ShadowIntensity : float : Read|Write
Get/set the value of the "Shadows" > "Intensity/Fade" option.

   

Methods:

NPR Settings

Accessing NPR Parameters

<void><ViewportViewSettingImpl>.ShowNPRParameters()

Prints information about the NPR mode to the Listener including Parameter Name, Type, Value and Range. Returns OK.

   

<string by value><ViewportViewSettingImpl>.GetNPRParameterInfo()

Returns a string value containing information about the NPR mode including Parameter Name, Type, Value and Range. Similar to ShowNPRParameters(), but returns the info as a string value instead of printing to the Listener.

   

<integer><ViewportViewSettingImpl>.GetNPRParameterCount()

Returns the number of parameters in the current NPR mode.

   

<string by value><ViewportViewSettingImpl>.GetNPRParameterName <integer>index

Returns the name of the indexed parameter. The index is zero-based. If the index is out of range, the value of "No Parameter" is returned.

   

<enum><ViewportViewSettingImpl>.GetNPRParameterType <integer>index 

GetNPRParameterType enums: { #Unknown | #Bool | #Int | #Float | #Float4 | #String }

Returns the type of the indexed parameter. The index is zero-based. If the index is out of range, the value of #Unknown is returned.

   

Accessing Boolean Parameters

<bool><ViewportViewSettingImpl>.GetNPRBool <string>name

Returns the value of the named boolean parameter of the current NPR mode.

   

<void><ViewportViewSettingImpl>.SetNPRBool <string>name <boolean>value

Sets the value of the named boolean parameter of the current NPR mode to the boolean value passed as second argument.

   

Accessing Integer Parameters

<integer><ViewportViewSettingImpl>.GetNPRInt <string>name

Returns the value of the named integer parameter of the current NPR mode.

   

<integer><ViewportViewSettingImpl>.GetNPRMinInt <string>name

Returns the minimum value of the named integer parameter of the current NPR mode.

   

<integer><ViewportViewSettingImpl>.GetNPRMaxInt <string>name

Returns the maximum value of the named integer parameter of the current NPR mode.

   

<void><ViewportViewSettingImpl>.SetNPRInt <string>name <integer>value

Sets the value of the named integer parameter of the current NPR mode to the integer value passed as second argument.

   

Accessing Float Parameters

<float><ViewportViewSettingImpl>.GetNPRFloat <string>name

Returns the value of the named float parameter of the current NPR mode.

   

<float><ViewportViewSettingImpl>.GetNPRMinFloat <string>name

Returns the minimum value of the named float parameter of the current NPR mode.

   

<float><ViewportViewSettingImpl>.GetNPRMaxFloat <string>name

Returns the maximum value of the named float parameter of the current NPR mode.

   

<void><ViewportViewSettingImpl>.SetNPRFloat <string>name <float>value

Sets the value of the named float parameter of the current NPR mode to the float value passed as second argument.

   

Accessing Float4 Parameters

<point4><ViewportViewSettingImpl>.GetNPRFloat4 <string>name

Returns the value of the named float4 parameter of the current NPR mode.

   

<point4><ViewportViewSettingImpl>.GetNPRMinFloat4 <string>name

Returns the minimum value of the named float4 parameter of the current NPR mode.

   

<point4><ViewportViewSettingImpl>.GetNPRMaxFloat4 <string>name

Returns the maximum value of the named float4 parameter of the current NPR mode.

   

<void><ViewportViewSettingImpl>.SetNPRFloat4 <string>name <point4>value

Sets the value of the named float4 parameter of the current NPR mode to the Point4 value passed as second argument.

   

Accessing String Parameters

<string by value><ViewportViewSettingImpl>.GetNPRString <string>name

Returns the value of the named string parameter of the current NPR mode.

   

<void><ViewportViewSettingImpl>.SetNPRString <string>name <string>value

Sets the value of the named string parameter of the current NPR mode to the string value passed as second argument.

   

EXAMPLE:

disp = NitrousGraphicsManager.GetActiveViewportSetting() 
for visStyle = 0 to 13 do 
(
 	disp.VisualStyleMode = visStyle
 	format "\n--Visual Style: %--\n\n" (disp.VisualStyleMode as string)
 	format "%\n" (disp.GetNPRParameterInfo())
 	local paramCount = disp.GetNPRParameterCount()
 	for p = 0 to paramCount-1 do
 	(
  		theName = (disp.GetNPRParameterName p)
  		theType = (disp.GetNPRParameterType p)
  		theValue = case theType of
  		(
   			#bool: disp.GetNPRBool theName
   			#int: disp.GetNPRInt theName
   			#float: disp.GetNPRFloat theName
   			#float4: disp.GetNPRFloat4 theName
   			#string: disp.GetNPRString theName
  		)
  		theRange = case theType of
  		(
   			#int: ("[" +disp.GetNPRMinInt theName as string + ", " + disp.GetNPRMaxInt theName as string + "]")
   			#float: ("[" +disp.GetNPRMinFloat theName as string + ", " + disp.GetNPRMaxFloat theName as string + "]")
   			#float4: ("[" +disp.GetNPRMinFloat4 theName as string + ", " + disp.GetNPRMaxFloat4 theName as string + "]")
   			default: ""
  		)
  		format "%: Name:\"%\" Type: % Value: % %\n" p theName (theType as string) theValue theRange
 	) 
)

   

The following scripted dialog exposes all parameters of the current Viewport Style Mode (if any) in a dynamic rollout for interactive tweaking. It also supports the NPR settings of the Quicksilver renderer and allows you to set the viewport and the renderer at the same time, thus giving an instant preview of the Quicksilver settings in the active viewport:

SCRIPT:

macroScript NPRExplorer category:"MXS Help"
(
	global Nitrous_NPR_Rollout, Nitrous_NPR_SubRollout
	global Nitrous_NPR_Settings = NitrousGraphicsManager.GetActiveViewportSetting()
	try(destroyDialog Nitrous_NPR_Rollout)catch()
	local theINIfile = (getDir #plugcfg + "\\Nitrous_NPR_Settings.ini")
	rcmenu Nitrous_NPR_Menu 
	(
		subMenu "File"
		(
			menuItem mnu_savePreset "SAVE Current Mode To Preset File..."
			menuItem mnu_loadPreset "LOAD Current Mode From Preset File..."
		)
		on mnu_savePreset picked do Nitrous_NPR_Rollout.savePreset()
		on mnu_loadPreset picked do Nitrous_NPR_Rollout.loadPreset()		
	)
	rollout Nitrous_NPR_Rollout "Nitrous NPR Settings"
	(
		
		radiobuttons rad_SystemToAffect labels:#("Views","Quicksilver","Both")
		dropdownlist ddl_NPRMode items:#("Realistic", "Shaded", "Facets", "ConsistentColors", "Wireframe", "BoundingBox", "Ink", "ColorInk", "Acrylic", "Tech", "Graphite", "ColorPencil", "Pastel")  height:15
		subRollout sub_rollout width:200 height:320

		fn createSubRollout source:1 =
		(
			try(removeSubRollout sub_rollout Nitrous_NPR_SubRollout)catch()
			Nitrous_NPR_Settings = case source of
			(
				default: NitrousGraphicsManager.GetActiveViewportSetting()
				2: renderers.current
			)
			currentMode = case source of
			(
				default: Nitrous_NPR_Settings.VisualStyleMode
				2: Nitrous_NPR_Settings.VisualStyle
			)
			local theString = "rollout Nitrous_NPR_SubRollout \"Nitrous:"+currentMode as string +" Mode\" width:200 (\n"
			local paramCount = Nitrous_NPR_Settings.GetNPRParameterCount()
			if paramCount == 0 do theString += "label lbl_1 \"The Current Shading Mode\"\n label lbl_2 \"Exposes No Parameters!\"\n"
			for p = 0 to paramCount-1 do
			(
				theName = Nitrous_NPR_Settings.GetNPRParameterName p
				case (Nitrous_NPR_Settings.GetNPRParameterType p) of
				(
					#int: (
							theRange= (Nitrous_NPR_Settings.GetNPRMinInt theName) as string + ", " + (Nitrous_NPR_Settings.GetNPRMaxInt theName) as string +", "+ (Nitrous_NPR_Settings.GetNPRInt theName) as string
							theString += "spinner spn_"+p as string + " \""+ theName + "\" type:#integer range:["+theRange+"] fieldwidth:50\n"
							theString += "on spn_"+p as string + " changed val do (::Nitrous_NPR_Settings.SetNPRInt \""+theName as string+"\" val; ::Nitrous_NPR_Rollout.updateRenderer())\n"
							)
					#float: (
							theRange = (Nitrous_NPR_Settings.GetNPRMinFloat theName) as string + ", " + (Nitrous_NPR_Settings.GetNPRMaxFloat theName) as string +", "+ (Nitrous_NPR_Settings.GetNPRFloat theName) as string
							theString += "spinner spn_"+p as string + " \""+ theName + "\" type:#float range:["+theRange+"] fieldwidth:50\n"
							theString += "on spn_"+p as string + " changed val do (::Nitrous_NPR_Settings.SetNPRFloat \""+theName as string+"\" val; ::Nitrous_NPR_Rollout.updateRenderer()) \n"
						)
					#float4: (
							theString += "colorpicker clr_"+p as string + " \""+ theName + "\" alpha:true align:#right color:["+(Nitrous_NPR_Settings.GetNPRFloat4 theName) as string+"] fieldwidth:50\n"
							theString += "on clr_"+p as string + " changed val do (::Nitrous_NPR_Settings.SetNPRFloat4 \""+theName as string+"\" (val as Point4); ::Nitrous_NPR_Rollout.updateRenderer())\n"
						)						
					#bool: (
							theString += "checkbox chk_"+p as string + " \""+ theName + "\" checked:"+(Nitrous_NPR_Settings.GetNPRBool theName) as string +"\n"
							theString += "on chk_"+p as string + " changed val do (::Nitrous_NPR_Settings.SetNPRBool \""+theName as string+"\" val; ::Nitrous_NPR_Rollout.updateRenderer())\n"
						)
					#string: (
							theString += "edittext edt_"+p as string + " \""+ theName + "\" text:\""+(Nitrous_NPR_Settings.GetNPRString theName) +"\" \n"
							theString += "on edt_"+p as string + " entered val do (::Nitrous_NPR_Settings.SetNPRString \""+theName as string+"\" val; ::Nitrous_NPR_Rollout.updateRenderer())\n"
						)						
				)--end case
			)--end p loop
			theString += ")"
			execute theString
			addSubRollout sub_rollout Nitrous_NPR_SubRollout
		)--end fn 	
		
		fn updateRenderer =
		(
			if rad_SystemToAffect.state == 3 do
			(
				renderers.current.VisualStyle = Nitrous_NPR_Settings.VisualStyleMode
				local paramCount = Nitrous_NPR_Settings.GetNPRParameterCount()
				for p = 0 to paramCount-1 do
				(
					local theName = Nitrous_NPR_Settings.GetNPRParameterName p
					case (Nitrous_NPR_Settings.GetNPRParameterType p) of
					(
						#int: (renderers.current.SetNPRInt theName (Nitrous_NPR_Settings.GetNPRInt theName))
						#float: (renderers.current.SetNPRFloat theName (Nitrous_NPR_Settings.GetNPRFloat theName))
						#float4: (renderers.current.SetNPRFloat4 theName (Nitrous_NPR_Settings.GetNPRFloat4 theName))
						#bool: (renderers.current.SetNPRBool theName (Nitrous_NPR_Settings.GetNPRBool theName))
						#string: (renderers.current.SetNPRString theName (Nitrous_NPR_Settings.GetNPRString theName))
					)--end case
				)--end p loop			
			)
		)		
		fn savePreset =
		(
			local theStyle = Nitrous_NPR_Settings.VisualStyleMode
			local paramCount = Nitrous_NPR_Settings.GetNPRParameterCount()
			if paramCount > 0 then
			(
				local theFile = getSaveFileName caption:("Save "+ theStyle as string +" Settings As...") types:"Nitrous NPR Presets (*.NPR)|*.NPR"
				if theFile != undefined do
				(
					for p = 0 to paramCount-1 do
					(
						local theName = Nitrous_NPR_Settings.GetNPRParameterName p
						local theFN = case (Nitrous_NPR_Settings.GetNPRParameterType p) of
						(
							#int: Nitrous_NPR_Settings.GetNPRInt
							#float: Nitrous_NPR_Settings.GetNPRFloat
							#float4: Nitrous_NPR_Settings.GetNPRFloat4
							#bool: Nitrous_NPR_Settings.GetNPRBool
							#string: Nitrous_NPR_Settings.GetNPRString
						)
						setIniSetting theFile (theStyle as string) (theName as string) ((theFN theName) as string)
					)--end p loop
				)
			)--end if
		)
		fn loadPreset =
		(
			local theStyle = Nitrous_NPR_Settings.VisualStyleMode
			local paramCount = Nitrous_NPR_Settings.GetNPRParameterCount()
			if paramCount > 0 then
			(
				local theFile = getOpenFileName caption:("Load "+ theStyle as string +" Settings From...") types:"Nitrous NPR Presets (*.NPR)|*.NPR"
				if theFile != undefined do
				(
					for p = 0 to paramCount-1 do
					(
						local theName = Nitrous_NPR_Settings.GetNPRParameterName p
						local theType = Nitrous_NPR_Settings.GetNPRParameterType p
						local theFN = case theType of
						(
							#int: Nitrous_NPR_Settings.SetNPRInt
							#float: Nitrous_NPR_Settings.SetNPRFloat
							#float4: Nitrous_NPR_Settings.SetNPRFloat4
							#bool: Nitrous_NPR_Settings.SetNPRBool
							#string: Nitrous_NPR_Settings.SetNPRString
						)
						local theVal = getIniSetting theFile (theStyle as string) (theName as string)
						if theVal != "" do
						(
							if theType != #string do theVal = execute theVal
							theFN theName theVal
						)
					)--end p loop
					createSubRollout source:rad_SystemToAffect.state
					updateRenderer()
				)--end if
			)--end if
		)		
		fn updateList =
		(
			local theMode = case rad_SystemToAffect.state of 
			( 
				default: Nitrous_NPR_Settings.VisualStyleMode
				2: Nitrous_NPR_Settings.VisualStyle
			)
			ddl_NPRMode.selection = findItem (for i in ddl_NPRMode.items collect i as name) theMode
		)
		on rad_SystemToAffect changed state do
		(
			local result = true
			local theClass = classof renderers.current
			if state > 1 and theClass != Quicksilver_Hardware_Renderer do 
			(
				result = querybox ("The current renderer is ["+theClass as string+"].\nClicking YES will replace it with Quicksilver.\n\nAre you sure you want to continue?") title:"Assign Quicksilver"
				if result then 
					renderers.current = Quicksilver_Hardware_Renderer()
			)
			if result then
			(
				createSubRollout source:state
				if state == 3 do updateRenderer()
				updateList()
			)
			else
				rad_SystemToAffect.state = 1
		)
		on ddl_NPRMode selected itm do
		(
			case rad_SystemToAffect.state of
			(
				default: Nitrous_NPR_Settings.VisualStyleMode =  ddl_NPRMode.selected as name
				2: Nitrous_NPR_Settings.VisualStyle =  ddl_NPRMode.selected as name
			)
			if rad_SystemToAffect.state == 3 do updateRenderer()
			createSubRollout source:rad_SystemToAffect.state
		)
		on Nitrous_NPR_Rollout open do 
		(
			createSubRollout()
			updateList()
		)
		on Nitrous_NPR_Rollout moved pos do
		(
			setIniSetting theINIfile "Dialog" "Position" (pos as string)
		)
	)
	local thePos = execute (getIniSetting theINIfile "Dialog" "Position")
	if thePos == OK do thePos = [100,100]
	createDialog Nitrous_NPR_Rollout 220 380 thePos.x thePos.y menu:Nitrous_NPR_Menu
)