ビューポート設定の IObject インタフェース:
Interface: ViewportViewSettingImpl
このインタフェースは、[ビューポート設定]ダイアログの[ビジュアル スタイルと外観]タブに表示されるビューポート設定を公開します。また、3ds Max 2012 のユーザ インタフェースには公開されないフォトリアリスティックではないレンダリング スタイルのパラメータへのスクリプトによるアクセスも提供します。
プロパティ:
コントロールのビジュアル スタイル グループ
<ViewportViewSettingImpl>.VisualStyleMode : enum : Read|Write
VisualStyleMode enums: { #Realistic | #Shaded | #Facets | #ConsistentColors | #HiddenLine | #Wireframe | #BoundingBox | #Ink | #ColorInk | #Acrylic | #Tech | #Graphite | #ColorPencil | #Pastel }
リアリスティック、シェーディング、およびフォトリアリスティックではないモードを含むビューポートのビジュアル スタイルを取得/設定します。このプロパティは、enum 名または整数値として設定できます。取得するときには、enum 名が返されます。
有効な値は次のとおりです。
数値 |
Enum 名 |
|
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
[エッジ面]ビューポート オプションの状態を取得/設定します。
false (既定値)に設定すると、エッジ面は表示されません。
true に設定すると、ジオメトリ面のワイヤフレーム表現がシェーディング面の上に重ねられます。
<ViewportViewSettingImpl>.UseTextureEnabled : bool : Read|Write
[テクスチャ]ビューポート オプションの状態を取得/設定します。
true (既定値)に設定すると、ビューポートにテクスチャ マップが表示されます(ビューポートでのテクスチャ マップの表示が有効になっている場合)。
false に設定すると、[ビューポートにマップを表示]の設定に関係なく、テクスチャ マップは表示されません。
<ViewportViewSettingImpl>.TransparencyEnabled : bool : Read|Write
[透明度]ビューポート オプションの状態を取得/設定します。
true (既定値)に設定すると、ビューポートに透明度が表示されます。
false に設定すると、透明度は無視され、すべてのオブジェクトがソリッド シェーディングで表示されます。
<ViewportViewSettingImpl>.UseEnvironmentBackgroundColorEnabled : bool : Read|Write
[環境バックグラウンド カラーを使用]ビューポート オプションの状態を取得/設定します。
false (既定値)に設定すると、[ユーザ インタフェースをカスタマイズ] > [カラー]タブ ダイアログの該当する値からビューポート バックグラウンド カラーが取得されます。
true に設定すると、[環境と効果]ダイアログ > [環境]タブ > [共通パラメータ]ロールアウト > コントロールの[バックグラウンド]グループで見つかった環境バックグラウンド カラーからビューポート バックグラウンド カラーが取得されます。
コントロールの選択グループ
<ViewportViewSettingImpl>.ShowSelectionBracketsEnabled : bool : Read|Write
[選択ブラケット]オプションの状態を取得/設定します。
true (既定値)に設定すると、選択されたオブジェクトが選択状態であることを示すシェーディング モードで選択ブラケットに表示されます。
false に設定すると、選択されたオブジェクトは選択ブラケットに表示されません。
.SelectedEdgeFacesEnabled
モードを有効にすると、選択状態であることを視覚的に示すことができます。
<ViewportViewSettingImpl>.SelectedEdgedFacesEnabled : bool : Read|Write
[選択をエッジ面で表示]オプションの状態を取得/設定します。
true に設定すると、選択されたオブジェクトがエッジ面で表示されます(シーンがシェーディング モードに設定されている場合)。
false (既定値)に設定すると、すべてのオブジェクトが現在のスタイルで表示されます。
<ViewportViewSettingImpl>.ShadeSelectedFacesEnabled : bool : Read|Write
[選択された面をシェーディング]オプションの状態を取得/設定します。
true (既定値)に設定すると、サブオブジェクト レベルの選択された面がソリッド カラーで表示されます。
false に設定すると、選択された面がカラー付きエッジでハイライトされます。
<ViewportViewSettingImpl>.ShadeSelectedObjectsEnabled : bool : Read|Write
[選択したオブジェクトをシェード]オプションの状態を取得/設定します。
true に設定すると、シーンがワイヤフレーム モードに設定されている場合でも、選択されたオブジェクトはシェーディング モードで表示されます。
false (既定値)に設定すると、すべてのオブジェクトが現在のスタイルで表示されます。
一般的なオプション
<ViewportViewSettingImpl>.DisableViewport : bool : Read|Write
[使用不能にする]オプションの状態を取得/設定します。
false (既定値)に設定すると、ビューポートが使用可能になり、必要に応じて再描画されます。
true に設定すると、ビューポートが使用不能になり、手動で強制した場合にのみ再描画されます。
<ViewportViewSettingImpl>.ViewportClippingEnabled : bool : Read|Write
[ビューポート クリッピング]オプションの状態を取得/設定します。
コントロールの照明グループ
<ViewportViewSettingImpl>.LightOption : enum : Read|Write
LightOption enums: { #DefaultLight | #SceneLight }
[照明] > [...で照明]ラジオ ボタンの状態を取得/設定します。
有効な値は次のとおりです。
#DefaultLight
-
.DefaultLightMode
プロパティに従って、1 つまたは 2 つの既定ライトを使用して照明します。
#SceneLight
- シーン ライトを使用して照明します。ただし、シーン ライトが存在しない場合は除きます。その場合、照明は既定ライトに戻ります。
<ViewportViewSettingImpl>.DefaultLightMode : enum : Read|Write
DefaultLightMode enums: { #OneLight | #TwoLights }
[既定値のライト]ラジオ ボタンの状態を取得/設定します。
有効な値は次のとおりです。
#OneLight
- カメラの後ろにある 1 つの「ヘッドライト」を使用してシーンを照明します。
#TwoLights
- 2 つの固定ライトを使用してシーンを照明します。
<ViewportViewSettingImpl>.ShowHighlightEnabled : bool : Read|Write
[ハイライト]オプションの状態を取得/設定します。
true (既定値)に設定すると、ビューポートで鏡面反射ハイライトが計算されます。
false に設定すると、ハイライトは計算されません。
<ViewportViewSettingImpl>.AutoDisplaySelectedLightEnabled : bool : Read|Write
コントロールのシャドウ グループ
<ViewportViewSettingImpl>.AmbientOcclusionEnabled : bool : Read|Write
[アンビエント オクルージョン]オプションの状態を取得/設定します。
false (既定値)に設定すると、アンビエント オクルージョンは計算されません。
true に設定すると、以下で説明する設定を使用して、スクリーンスペースのアンビエント オクルージョン効果が計算されます。
<ViewportViewSettingImpl>.AmbientOcclusionRadius : float : Read|Write
[アンビエント オクルージョン] > [半径]値を取得/設定します。
<ViewportViewSettingImpl>.AmbientOcclusionIntensity : float : Read|Write
[アンビエント オクルージョン] > [強度/フェード]値を取得/設定します。
<ViewportViewSettingImpl>.ShadowsEnabled : bool : Read|Write
[シャドウ]オプションの状態を取得/設定します。
false (既定値)に設定すると、ビューポートにシャドウが表示されません。
true に設定すると、以下で説明する品質設定を使用して、ビューポートで影付けが有効になっているライトにビューポート シャドウも表示されます。
<ViewportViewSettingImpl>.ShadowMode : enum : Read|Write
ShadowMode enums: { #HardShadow | #SoftShadow | #LightSettingShadow }
シャドウ スタイル(ハード シャドウ、ソフト シャドウ)またはライト ソース自体で定義されているシャドウ タイプを取得/設定します。
<ViewportViewSettingImpl>.ShadowIntensity : float : Read|Write
[シャドウ] >
[強度/フェード]オプションの値を取得/設定します。
メソッド:
NPR 設定
NPR パラメータへのアクセス
<void><ViewportViewSettingImpl>.ShowNPRParameters()
パラメータ名、タイプ、値、範囲などの NPR モードに関する情報をリスナーに出力します。OK を返します。
<string by value><ViewportViewSettingImpl>.GetNPRParameterInfo()
パラメータ名、タイプ、値、範囲などの NPR モードに関する情報を含む文字列値を返します。
ShowNPRParameters()
に似ていますが、情報をリスナーに出力するのではなく、文字列値として返します。
<integer><ViewportViewSettingImpl>.GetNPRParameterCount()
現在の NPR モードのパラメータの数を返します。
<string by value><ViewportViewSettingImpl>.GetNPRParameterName <integer>index
インデックスで指定されたパラメータの名前を返します。インデックスの基数はゼロです。インデックスが範囲外の場合は、「パラメータなし」が値として返されます。
<enum><ViewportViewSettingImpl>.GetNPRParameterType <integer>index
GetNPRParameterType enums: { #Unknown | #Bool | #Int | #Float | #Float4 | #String }
インデックスで指定されたパラメータのタイプを返します。インデックスの基数はゼロです。インデックスが範囲外の場合は、#Unknown が値として返されます。
ブール パラメータへのアクセス
<bool><ViewportViewSettingImpl>.GetNPRBool <string>name
現在の NPR モードの指定されたブール パラメータの値を返します。
<void><ViewportViewSettingImpl>.SetNPRBool <string>name <boolean>value
現在の NPR モードの指定されたブール パラメータの値を、2 番目の引数として渡されたブール値に設定します。
整数パラメータへのアクセス
<integer><ViewportViewSettingImpl>.GetNPRInt <string>name
現在の NPR モードの指定された整数パラメータの値を返します。
<integer><ViewportViewSettingImpl>.GetNPRMinInt <string>name
現在の NPR モードの指定された整数パラメータの最小値を返します。
<integer><ViewportViewSettingImpl>.GetNPRMaxInt <string>name
現在の NPR モードの指定された整数パラメータの最大値を返します。
<void><ViewportViewSettingImpl>.SetNPRInt <string>name <integer>value
現在の NPR モードの指定された整数パラメータの値を、2 番目の引数として渡された整数値に設定します。
実数パラメータへのアクセス
<float><ViewportViewSettingImpl>.GetNPRFloat <string>name
現在の NPR モードの指定された実数パラメータの値を返します。
<float><ViewportViewSettingImpl>.GetNPRMinFloat <string>name
現在の NPR モードの指定された実数パラメータの最小値を返します。
<float><ViewportViewSettingImpl>.GetNPRMaxFloat <string>name
現在の NPR モードの指定された実数パラメータの最大値を返します。
<void><ViewportViewSettingImpl>.SetNPRFloat <string>name <float>value
現在の NPR モードの指定された実数パラメータの値を、2 番目の引数として渡された実数値に設定します。
Float4 パラメータへのアクセス
<point4><ViewportViewSettingImpl>.GetNPRFloat4 <string>name
現在の NPR モードの指定された float4 パラメータの値を返します。
<point4><ViewportViewSettingImpl>.GetNPRMinFloat4 <string>name
現在の NPR モードの指定された float4 パラメータの最小値を返します。
<point4><ViewportViewSettingImpl>.GetNPRMaxFloat4 <string>name
現在の NPR モードの指定された float4 パラメータの最大値を返します。
<void><ViewportViewSettingImpl>.SetNPRFloat4 <string>name <point4>value
現在の NPR モードの指定された float4 パラメータの値を、2 番目の引数として渡された Point4 値に設定します。
文字列パラメータへのアクセス
<string by value><ViewportViewSettingImpl>.GetNPRString <string>name
現在の NPR モードの指定された文字列パラメータの値を返します。
<void><ViewportViewSettingImpl>.SetNPRString <string>name <string>value
現在の NPR モードの指定された文字列パラメータの値を、2 番目の引数として渡された文字列値に設定します。
例:
|
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
)
)
|
次のスクリプト ダイアログでは、現在のビューポート スタイル モードのすべてのパラメータ(存在する場合)をダイナミック ロールアウトで公開し、インタラクティブにツイークできるようにします。このダイアログでは、Quicksilver レンダラーの
NPR 設定もサポートされ、ビューポートとレンダラーを同時に設定できます。そのため、アクティブなビューポートの Quicksilver 設定を即座にプレビューできます。
スクリプト:
|
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
)
|